Skip to content

Commit b658f65

Browse files
committed
pre-commit fix
1 parent b3891e9 commit b658f65

2 files changed

Lines changed: 27 additions & 25 deletions

File tree

notebooks/Getting_started.ipynb

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@
811811
"OCEAN_GRID_FOLDERS = \"output401/ocean/\" # Specific folder for ocean grid files\n",
812812
"\n",
813813
"print(f\"Using dataset from: {ROOT_FOLDER}\")\n",
814-
"print(f\"Target folders:\")\n",
814+
"print(\"Target folders:\")\n",
815815
"print(f\" Atmosphere: {ATMOS_FOLDERS}\")\n",
816816
"print(f\" Ocean: {OCEAN_FOLDERS}\")\n",
817817
"print(f\" Land: {LAND_FOLDERS}\")\n",
@@ -863,14 +863,14 @@
863863
"outputs": [],
864864
"source": [
865865
"parent_experiment_config = {\n",
866-
" \"parent_experiment_id\": \"piControl-spinup\", # <-- This is for placeholder.\n",
866+
" \"parent_experiment_id\": \"piControl-spinup\", # <-- This is for placeholder.\n",
867867
" \"parent_activity_id\": \"CMIP\",\n",
868-
" \"parent_source_id\": \"ACCESS-ESM1-5\", # <-- ACCESS-ESM1-6 is not yet registered in the CMIP6 catalog, so we use ACCESS-ESM1-5 as a placeholder\n",
868+
" \"parent_source_id\": \"ACCESS-ESM1-5\", # <-- ACCESS-ESM1-6 is not yet registered in the CMIP6 catalog, so we use ACCESS-ESM1-5 as a placeholder\n",
869869
" \"parent_variant_label\": \"r1i1p1f1\",\n",
870870
" \"parent_time_units\": \"days since 0001-01-01 00:00:00\",\n",
871871
" \"parent_mip_era\": \"CMIP6\",\n",
872-
" \"branch_time_in_child\": 0.0, # <-- This is for placeholder. The actual branch time in child should be the time of the first time step in the input data, converted to the parent time units.\n",
873-
" \"branch_time_in_parent\": 54786.0, # <-- This is the branch time in parent for the December Spin-up run, which is the time of the first time step in the input data (1850-12-01), converted to the parent time units (days since 0001-01-01).\n",
872+
" \"branch_time_in_child\": 0.0, # <-- This is for placeholder. The actual branch time in child should be the time of the first time step in the input data, converted to the parent time units.\n",
873+
" \"branch_time_in_parent\": 54786.0, # <-- This is the branch time in parent for the December Spin-up run, which is the time of the first time step in the input data (1850-12-01), converted to the parent time units (days since 0001-01-01).\n",
874874
" \"branch_method\": \"standard\",\n",
875875
"}"
876876
]
@@ -904,7 +904,7 @@
904904
" input_data=files,\n",
905905
" compound_name=\"Amon.rsds\",\n",
906906
" experiment_id=\"piControl-spinup\",\n",
907-
" source_id=\"ACCESS-ESM1-5\", # <-- ACCESS-ESM1-6 is not yet registered in the CMIP6 catalog, so we use ACCESS-ESM1-5 as a placeholder\n",
907+
" source_id=\"ACCESS-ESM1-5\", # <-- ACCESS-ESM1-6 is not yet registered in the CMIP6 catalog, so we use ACCESS-ESM1-5 as a placeholder\n",
908908
" variant_label=\"r1i1p1f1\",\n",
909909
" grid_label=\"gn\",\n",
910910
" activity_id=\"CMIP\",\n",
@@ -1157,9 +1157,7 @@
11571157
"\n",
11581158
"# Find ocean salinity files using the utility function with explicit paths\n",
11591159
"ocean_files = get_monthly_ocean_files(\n",
1160-
" \"Omon.so\", \n",
1161-
" root_folder=ROOT_FOLDER,\n",
1162-
" target_folders=OCEAN_FOLDERS\n",
1160+
" \"Omon.so\", root_folder=ROOT_FOLDER, target_folders=OCEAN_FOLDERS\n",
11631161
")\n",
11641162
"print(f\"Ocean files: {ocean_files[:2]}...\") # Show first 2 files"
11651163
]
@@ -1388,7 +1386,7 @@
13881386
" grid_label=\"gn\",\n",
13891387
" activity_id=\"CMIP\",\n",
13901388
" parent_info=parent_experiment_config,\n",
1391-
" cmip_version=\"CMIP7\" # <---- Explicit CMIP7 support (Default is still CMIP6)\n",
1389+
" cmip_version=\"CMIP7\", # <---- Explicit CMIP7 support (Default is still CMIP6)\n",
13921390
")\n",
13931391
"\n",
13941392
"# Display the CMIP7 variable mapping\n",

src/access_moppy/utilities.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -145,44 +145,44 @@ def load_model_mappings(compound_name: str, model_id: str = None) -> Dict:
145145

146146

147147
def get_monthly_ocean_files(
148-
compound_name: str,
148+
compound_name: str,
149149
root_folder: str = "/g/data/p73/archive/CMIP7/ACCESS-ESM1-6/spinup/Dec25-PI-control/",
150150
target_folders: str = "output40[0-9]/ocean/",
151-
model_id: str = "ACCESS-ESM1.6"
151+
model_id: str = "ACCESS-ESM1.6",
152152
) -> List[str]:
153153
"""
154154
Find ocean data files for a given CMOR variable.
155-
156-
This utility function searches for ocean model output files that correspond to a
157-
specific CMIP variable by using the variable mapping to identify the required
155+
156+
This utility function searches for ocean model output files that correspond to a
157+
specific CMIP variable by using the variable mapping to identify the required
158158
model variables and then searching for files with the ocean-specific naming pattern.
159-
159+
160160
Args:
161161
compound_name: CMOR compound name (e.g., 'Omon.so', 'Ofx.areacello')
162162
root_folder: Root directory to search for files (default: ACCESS-ESM1.6 Dec spin-up path)
163163
target_folders: Target folder pattern relative to root_folder (default: output40[0-9]/ocean/)
164164
model_id: Model identifier for loading mappings (default: ACCESS-ESM1.6)
165-
165+
166166
Returns:
167167
List of absolute paths to matching ocean files
168-
168+
169169
Raises:
170170
ValueError: If compound_name format is invalid
171171
FileNotFoundError: If root directory doesn't exist
172-
172+
173173
Examples:
174174
>>> # Find ocean salinity files
175175
>>> files = get_monthly_ocean_files("Omon.so")
176176
>>> print(f"Found {len(files)} salinity files")
177-
177+
178178
>>> # Find ocean cell area files (different location)
179179
>>> area_files = get_monthly_ocean_files(
180180
... "Ofx.areacello",
181181
... target_folders="output401/ocean/"
182182
... )
183183
"""
184184
import glob
185-
185+
186186
# Validate inputs
187187
if not compound_name or "." not in compound_name:
188188
raise ValueError(
@@ -247,18 +247,22 @@ def get_monthly_ocean_files(
247247
# Only warn if no alternatives were tried
248248
warnings.warn(
249249
f"No files found for model variable '{model_variable}' with pattern: {search_pattern}",
250-
UserWarning
250+
UserWarning,
251251
)
252252

253253
except Exception as e:
254-
warnings.warn(f"Error searching for files with pattern '{search_pattern}': {e}")
254+
warnings.warn(
255+
f"Error searching for files with pattern '{search_pattern}': {e}"
256+
)
255257

256258
# Remove duplicates and sort
257259
files_found = sorted(list(set(files_found)))
258260

259261
if not files_found:
260-
warnings.warn(f"No ocean files found for {compound_name} in {search_pattern_base}")
261-
262+
warnings.warn(
263+
f"No ocean files found for {compound_name} in {search_pattern_base}"
264+
)
265+
262266
return files_found
263267

264268

0 commit comments

Comments
 (0)