66the output directory.
77
88The file
9- `Variables_will_be_in_NetCDF_file .csv <https://github.com/EcoExtreML/STEMMUS_SCOPE/blob/main/utils/csv_to_nc/Variables_will_be_in_NetCDF_file .csv>`_
9+ `required_netcf_variables .csv <https://github.com/EcoExtreML/STEMMUS_SCOPE/blob/main/utils/csv_to_nc/required_netcf_variables .csv>`_
1010lists required variable names and their attributes based on `ALMA+CF
1111convention table <https://docs.google.com/spreadsheets/d/1CA3aTvI9piXqRqO-3MGrsH1vW-Sd87D8iZXHGrqK42o/edit#gid=2085475627>`_.
1212
1818 >>>model = StemmusScope(config_file, exe_file)
1919 >>>model.setup()
2020 >>>model.run()
21- >>>save.to_netcdf(model.config, "Variables_will_be_in_NetCDF_file .csv")
21+ >>>save.to_netcdf(model.config, "required_netcf_variables .csv")
2222
2323"""
2424
3636
3737logger = logging .getLogger (__name__ )
3838
39+ DATASET_ATTRS = {
40+ 'model' : 'STEMMUS_SCOPE' ,
41+ 'institution' : 'University of Twente; Northwest A&F University' ,
42+ 'contact' : (
43+ 'Zhongbo Su, z.su@utwente.nl; '
44+ 'Yijian Zeng, y.zeng@utwente.nl; '
45+ 'Yunfei Wang, y.wang-3@utwente.nl'
46+ ),
47+ 'license_type' : 'CC BY 4.0' ,
48+ 'license_url' : 'https://creativecommons.org/licenses/by/4.0/' ,
49+ }
50+
3951
4052def _select_forcing_variables (forcing_dict : Dict , forcing_var : str , alma_var : str ) -> xr .DataArray :
4153 """Select the variable needed by ALMA convention.
@@ -218,19 +230,9 @@ def _update_dataset_attrs_dims(dataset: xr.Dataset, forcing_dict: Dict) -> xr.Da
218230 # additional metadata
219231 lat = forcing_dict ["latitude" ]
220232 lon = forcing_dict ["longitude" ]
221- dataset_reordered .attrs = {
222- 'model' : 'STEMMUS_SCOPE' ,
223- 'institution' : 'University of Twente; Northwest A&F University' ,
224- 'contact' : (
225- 'Zhongbo Su, z.su@utwente.nl; '
226- 'Yijian Zeng, y.zeng@utwente.nl; '
227- 'Yunfei Wang, y.wang-3@utwente.nl'
228- ),
229- 'license_type' : 'CC BY 4.0' ,
230- 'license_url' : 'https://creativecommons.org/licenses/by/4.0/' ,
231- 'latitude' : lat ,
232- 'longitude' : lon ,
233- }
233+ dataset_reordered .attrs = DATASET_ATTRS
234+ dataset_reordered .attrs ['latitude' ] = lat
235+ dataset_reordered .attrs ['longitude' ] = lon
234236
235237 # update values of x and y coords
236238 dataset = dataset_reordered .assign_coords (
@@ -298,7 +300,7 @@ def to_netcdf(config: Dict, cf_filename: str) -> str:
298300 data_list = []
299301 for alma_name in alma_short_names :
300302 df = conventions .loc [alma_short_names == alma_name ].iloc [0 ]
301- file_name = Path (config ["OutputPath" ]) / df ["File name " ]
303+ file_name = Path (config ["OutputPath" ]) / df ["file_name_STEMMUS-SCOPE " ]
302304
303305 if alma_name in var_names :
304306 # select data
@@ -310,15 +312,15 @@ def to_netcdf(config: Dict, cf_filename: str) -> str:
310312 data_array = _prepare_soil_data (file_name , alma_name , time .values )
311313 else :
312314 data_array = _prepare_simulated_data (
313- file_name , df ["Variable name in STEMMUS -SCOPE" ], alma_name , time .values
315+ file_name , df ["short_name_STEMMUS -SCOPE" ], alma_name , time .values
314316 )
315317
316318 # update attributes of array
317319 data_array .attrs = {
318320 "units" : df ["unit" ],
319321 "long_name" : df ["long_name" ],
320322 "standard_name" : df ["standard_name" ],
321- "STEMMUS-SCOPE_name" : df ["Variable name in STEMMUS -SCOPE" ],
323+ "STEMMUS-SCOPE_name" : df ["short_name_STEMMUS -SCOPE" ],
322324 "definition" : df ["definition" ],
323325 }
324326
0 commit comments