@@ -23,8 +23,9 @@ def process_grid_inputs(grid_config):
2323 var_name = find_main_var (ds , 3 )
2424 da = ds [var_name ]
2525 logger .info (f"Xarray created from source:\n { da } \n " )
26- gridx_colname = grid_config .get ("coord_x" , "lat" )
27- gridy_colname = grid_config .get ("coord_y" , "lon" )
26+ coord_config = grid_config .get ("coords" , {})
27+ gridx_colname = coord_config .get ("x" , "lat" )
28+ gridy_colname = coord_config .get ("y" , "lon" )
2829 da = da .sortby ([gridx_colname , gridy_colname ])
2930 shape = da [gridx_colname ].shape [0 ], da [gridy_colname ].shape [0 ]
3031 return da , var_name , gridx_colname , gridy_colname , shape
@@ -93,11 +94,9 @@ def process_inputs(station_config, grid_config):
9394 unique_indices , duplication_indexes = np .unique (df [index_1d_config ].values , return_inverse = True )
9495 grid_config ["source" ]["gribjump" ]["indices" ] = unique_indices
9596 masked_da = load_ekd_source (grid_config )
96- # TODO: implement
97- da_varname = "placeholder_variable_name"
98-
9997 var_name = find_main_var (masked_da , 2 )
10098 masked_da = masked_da [var_name ]
99+ da_varname = var_name
101100 else :
102101 da , da_varname , gridx_colname , gridy_colname , shape = process_grid_inputs (grid_config )
103102
@@ -142,10 +141,9 @@ def apply_mask(da, mask, coordx, coordy):
142141
143142def extractor (config ):
144143 da_varname , station_names , duplication_indexes , masked_da = process_inputs (config ["station" ], config ["grid" ])
145- print (masked_da )
146144 ds = xr .Dataset ({da_varname : masked_da })
147145 ds = ds .isel (index = duplication_indexes )
148- ds [ "station" ] = station_names
146+ ds = ds . assign_coords ({ "station" : ( "index" , station_names )})
149147 if config .get ("output" , None ) is not None :
150148 logger .info (f"Saving output to { config ['output' ]['file' ]} " )
151149 ds .to_netcdf (config ["output" ]["file" ])
0 commit comments