@@ -936,6 +936,7 @@ def execute_pyciam(
936936 tmp_output_path = AnyPath ("pyciam_tmp_results.zarr" ),
937937 remove_tmpfile = True ,
938938 overwrite = False ,
939+ no_surge_check = False ,
939940 mc_dim = "quantile" ,
940941 seg_var = "seg_adm" ,
941942 seg_var_subset = None ,
@@ -1019,6 +1020,8 @@ def execute_pyciam(
10191020 want to examine seg-adm level results.
10201021 ovewrwrite : bool, default False
10211022 If True, overwrite all intermediate output files
1023+ no_surge_check : bool, default False
1024+ If True, assume surge lookup tables are complete and do not load to check.
10221025 mc_dim : str, default "quantile"
10231026 The dimension of the sea level rise datasets specified at `slr_input_paths` that
10241027 indexes different simulations within the same scenario. This could reflect Monte
@@ -1079,12 +1082,12 @@ def execute_pyciam(
10791082 some environment variables in order for the :py:mod:`cloudpathlib` objects to
10801083 function correctly. For example, if your data exists on Google Cloud Storage and
10811084 requires authentication, you would need to set the
1082- `GOOGLE_APPLICATION_CREDENTIALS` environment variable to the same path as
1083- reflected in `storage_options["token"]`. Other cloud storage providers will have
1085+ `` GOOGLE_APPLICATION_CREDENTIALS` ` environment variable to the same path as
1086+ reflected in `` storage_options["token"]` `. Other cloud storage providers will have
10841087 different authentication methods and have not yet been tested with this
10851088 function.
10861089 params_override : dict, default {}
1087- Used to override params specified in `params_path`
1090+ Used to override params specified in `` params_path``.
10881091 **model_kwargs
10891092 Passed directly to :py:func:`pyCIAM.calc_costs`
10901093 """
@@ -1176,7 +1179,7 @@ def execute_pyciam(
11761179 for var , path in surge_input_paths .items ():
11771180 if path is None :
11781181 continue
1179- if overwrite or not path . is_dir () :
1182+ if not no_surge_check :
11801183 if var == seg_var :
11811184 this_econ_input = econ_input_path
11821185 elif var == "seg" :
@@ -1199,7 +1202,7 @@ def execute_pyciam(
11991202 slr_0_years = params .slr_0_year ,
12001203 client = client ,
12011204 client_kwargs = {"batch_size" : surge_batchsize },
1202- force_overwrite = True ,
1205+ force_overwrite = overwrite ,
12031206 seg_chunksize = surge_seg_chunksize ,
12041207 mc_dim = mc_dim ,
12051208 storage_options = storage_options ,
@@ -1272,7 +1275,7 @@ def execute_pyciam(
12721275
12731276 # add attrs
12741277 out_ds .attrs .update (attr_dict )
1275- out_ds = add_attrs_to_result (out_ds )
1278+ out_ds = add_attrs_to_result (out_ds , seg_var )
12761279
12771280 if overwrite or not tmp_output_path .is_dir ():
12781281 out_ds .to_zarr (
@@ -1340,7 +1343,10 @@ def execute_pyciam(
13401343 i += most_segadm
13411344 else :
13421345 this_group = this_group .isel (
1343- {seg_var : this_group .seg != this_group .seg .isel (seg_adm = - 1 , drop = True )}
1346+ {
1347+ seg_var : this_group .seg
1348+ != this_group .seg .isel ({seg_var : - 1 }, drop = True )
1349+ }
13441350 )
13451351 i += len (this_group [seg_var ])
13461352
@@ -1378,7 +1384,17 @@ def execute_pyciam(
13781384 ** model_kwargs ,
13791385 )
13801386 )
1381-
1387+ return xr .concat (
1388+ client .gather (
1389+ client .map (
1390+ optimize_case_seg ,
1391+ ciam_futs ,
1392+ dfact = test_inputs .dfact ,
1393+ npv_start = test_inputs .npv_start ,
1394+ )
1395+ ),
1396+ dim = "seg" ,
1397+ )
13821398 if output_path is None and seg_var == "seg" :
13831399 out = add_attrs_to_result (
13841400 xr .concat (
@@ -1391,7 +1407,8 @@ def execute_pyciam(
13911407 )
13921408 ),
13931409 dim = "seg" ,
1394- )
1410+ ),
1411+ seg_var ,
13951412 )
13961413 out .attrs .update (attr_dict )
13971414 return out
0 commit comments