Skip to content

Commit

Permalink
piControl prototype workflow done #3
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas-Moore-Creative committed Dec 4, 2024
1 parent 94419fe commit d74fe37
Show file tree
Hide file tree
Showing 6 changed files with 386 additions and 894 deletions.
5 changes: 3 additions & 2 deletions ACDtools/ard.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,13 @@ def find_chunking_info(catalog_search, var_name, return_results=False):
else:
return None

def save_n_drop_multidim_lat_lon(ds, save_coords_dir, coords_name='ACCESS-ESM1.5'):
def save_n_drop_multidim_lat_lon(ds, save_coords_dir, coords_name='ACCESS-ESM1.5', variable_name='var_name_unknown'):
coords = ds[['latitude', 'longitude','vertices_latitude','vertices_longitude']]
current_datetime = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
filename = f"{coords_name}_{current_datetime}_coords.nc"
filename = f"{coords_name}_{variable_name}_coords_{current_datetime}.nc"
coords.to_netcdf(save_coords_dir + filename)
ds_dropped = ds.drop(['latitude','longitude','vertices_latitude','vertices_longitude'])
ds_dropped.attrs['coords_filename'] = save_coords_dir + filename
ds_dropped.attrs['NOTE on coordinates'] = 'the multidimensional latitude and longitude coordinates have been saved as a separate NetCDF file'
return ds_dropped

4 changes: 3 additions & 1 deletion ACDtools/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def var_name_info(catalog_object, var_name, return_results=False):
var_info : dict or None
A dictionary containing the variable information (returned only if `return_results=True`).
"""
var_ds = xr.open_mfdataset((catalog_object.search(file_type='l',
var_ds = xr.open_mfdataset((catalog_object.search(
variable_id=var_name).unique().path)[0], chunks={})
var_info = var_ds[var_name].attrs
# turn the dictionary into a table for easy reading - adding a header that reports the variable name and name of the catalog object
Expand Down Expand Up @@ -312,6 +312,8 @@ def remove_encoding(DS):
for coord in DS.coords:
DS[coord].encoding = {}
return DS





Expand Down
2 changes: 1 addition & 1 deletion config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ catalog_search_query_dict:
CLEX_catalog:
experiment_id: ['piControl'] #,'historical','ssp370']
source_id: 'ACCESS-ESM1-5'
variable_id: ['thetao']
variable_id: ['u']
table_id: 'Omon'
chunking:
ACCESS_ESM15_2D: #{'chunks':{'member':1,'time':220,'j':300,'i':360}}
Expand Down
4 changes: 2 additions & 2 deletions job_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ dask_cluster:
threads_per_worker: None # Default threads per worker
memory_limit: None # Default Memory limit per worker
catalog_search_query_dict:
experiment_id: 'piControl'
experiment_id: 'ssp126'
source_id: 'ACCESS-ESM1-5'
variable_id: 'thetao'
variable_id: 'vo'
table_id: 'Omon'
chunking_key:
'ACCESS_ESM15_3D'
Expand Down
Loading

0 comments on commit d74fe37

Please sign in to comment.