@@ -197,24 +197,26 @@ def assert_year(img_src, year, tiles_gdf):
197197 tiles_gdf (GeoDataframe): tiles geodataframe
198198 """
199199
200-
201200 try :
202- assert year == 'multi-year' and 'year_tile' in tiles_gdf .keys () or str (year ).isnumeric () and 'year_tile' not in tiles_gdf .keys ()
201+ assert ( year == 'multi-year' and 'year_tile' in tiles_gdf .keys ()) or ( str (year ).isnumeric () and 'year_tile' not in tiles_gdf .keys () and img_src != 'WMS' and img_src != 'MIL' )
203202 except :
204203 if year == 'multi-year' :
205- logger .error ("Option 'multi-year' chosen but the tile geodataframe does not contain a year column. "
206- "Please add it or set a numeric year in the configuration file." )
204+ logger .error ("Option 'multi-year' chosen but the tile geodataframe does not contain a ' year' column."
205+ "Please add it while producing the tile geodtaframe or set a numeric year in the configuration file." )
207206 sys .exit (1 )
208207 elif year :
209- logger .error ("Option 'year' chosen but the tile geodataframe contains a year column. "
210- "Please delete it or set the 'multi-year' option in the configuration file. " )
211- sys .exit (1 )
208+ if img_src == 'WMS' or img_src == 'MIL' :
209+ logger .error ("The connectors WMS and MIL do not support year information. The input year will be ignored." )
210+ else :
211+ logger .error ("Option 'year' chosen but the tile geodataframe contains a 'year' column."
212+ "Please delete it while producing the tile geodtaframe or set the 'multi-year' option in the configuration file." )
213+ sys .exit (1 )
212214 elif 'year_tile' in tiles_gdf .keys ():
213- if img_src == 'WMS' :
214- logger .error ("Connector= WMS, delete the year column in the tile geodataframe" )
215+ if img_src == 'WMS' or img_src == 'MIL' :
216+ logger .error ("The connectors WMS and MIL do not support year information. Please provide a tile geodataframe without it. " )
215217 else :
216- logger .error ("Option 'year' not chosen but the tile geodataframe contains a year column. "
217- "Please delete it or set the 'year: multi-year' in the configuration file." )
218+ logger .error ("Option 'year' not chosen but the tile geodataframe contains a ' year' column. "
219+ "Please delete it while producing the tile geodtaframe or set the 'multi-year' option in the configuration file." )
218220 sys .exit (1 )
219221
220222
@@ -489,7 +491,11 @@ def main(cfg_file_path):
489491 if IM_SOURCE_TYPE == 'MIL' :
490492
491493 logger .info ("(using the MIL connector)" )
492-
494+
495+ assert_year (IM_SOURCE_TYPE , YEAR , aoi_tiles_gdf )
496+ if YEAR :
497+ YEAR = None
498+
493499 job_dict = MIL .get_job_dict (
494500 tiles_gdf = aoi_tiles_gdf .to_crs (IM_SOURCE_SRS ), # <- note the reprojection
495501 mil_url = IM_SOURCE_LOCATION ,
@@ -508,6 +514,8 @@ def main(cfg_file_path):
508514 logger .info ("(using the WMS connector)" )
509515
510516 assert_year (IM_SOURCE_TYPE , YEAR , aoi_tiles_gdf )
517+ if YEAR :
518+ YEAR = None
511519
512520 job_dict = WMS .get_job_dict (
513521 tiles_gdf = aoi_tiles_gdf .to_crs (IM_SOURCE_SRS ), # <- note the reprojection
@@ -799,6 +807,10 @@ def main(cfg_file_path):
799807 for dst in split_aoi_tiles_with_img_md_gdf .dataset .to_numpy ():
800808 os .makedirs (os .path .join (OUTPUT_DIR , f'{ dst } -images{ f"-{ TILE_SIZE } " if TILE_SIZE else "" } ' ), exist_ok = True )
801809
810+ for src_file , dataset in zip (split_aoi_tiles_with_img_md_gdf .img_file , split_aoi_tiles_with_img_md_gdf .dataset ):
811+ print (src_file )
812+ print (dataset )
813+ # exit()
802814 split_aoi_tiles_with_img_md_gdf ['dst_file' ] = [
803815 src_file .replace ('all' , dataset )
804816 for src_file , dataset in zip (split_aoi_tiles_with_img_md_gdf .img_file , split_aoi_tiles_with_img_md_gdf .dataset )
0 commit comments