File tree Expand file tree Collapse file tree 4 files changed +13
-4
lines changed
Expand file tree Collapse file tree 4 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 1+ import os
2+
13import numpy as np
24import xarray as xr
35
@@ -7,8 +9,14 @@ class Supergrid(object):
79 # https://gist.github.com/rbeucher/b67c2b461557bc215a70017ea8dd337b
810
911 def __init__ (self , supergrid_file ):
10- self .supergrid_file = supergrid_file
11- self .supergrid = xr .open_dataset (supergrid_file )
12+ if isinstance (supergrid_file , list ):
13+ self .supergrid_file_list = supergrid_file
14+ self .supergrid = xr .open_mfdataset (self .supergrid_file_list )
15+ elif os .path .isfile (supergrid_file ):
16+ self .supergrid_file = supergrid_file
17+ self .supergrid = xr .open_dataset (supergrid_file )
18+ else :
19+ raise ValueError ("Couldn't find supergrid file" )
1220
1321 # T point locations
1422 self .xt = self .supergrid ["x" ][1 ::2 , 1 ::2 ]
Original file line number Diff line number Diff line change 1+ import glob
12import importlib .resources as resources
23from pathlib import Path
34
@@ -139,7 +140,7 @@ def test_cmorise_OM3_2d(model_om3, cmor_name):
139140 DATA_DIR / f"om3/2d/access-om3.mom6.2d.{ cmor_name } .1mon.mean.1902_01.nc"
140141 )
141142 try :
142- model_om3 .supergrid = DATA_DIR / "supergrid/ocean_hgrid .nc"
143+ model_om3 .supergrid = glob . glob ( str ( DATA_DIR / "om3/ supergrid/* .nc" ))
143144 model_om3 .cmorise (
144145 file_paths = file_pattern ,
145146 compound_name = "Omon." + cmor_name ,
@@ -158,7 +159,7 @@ def test_cmorise_OM3_3d(model_om3, cmor_name):
158159 DATA_DIR / f"om3/3d/access-om3.mom6.3d.{ cmor_name } .1mon.mean.1924_01.nc"
159160 )
160161 try :
161- model_om3 .supergrid = DATA_DIR / "supergrid/ocean_hgrid .nc"
162+ model_om3 .supergrid = glob . glob ( str ( DATA_DIR / "om3/ supergrid/* .nc" ))
162163 model_om3 .cmorise (
163164 file_paths = file_pattern ,
164165 compound_name = "Omon." + cmor_name ,
You can’t perform that action at this time.
0 commit comments