Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop mhw merge to main branch #41

Merged
merged 21 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ dependencies:
- xesmf
- pytest
- beautifulsoup4
- matplotlib
31 changes: 12 additions & 19 deletions mom6/mom6_module/deprecated/mom6_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,19 @@
import xarray as xr
from scipy.stats import norm as normal
from mom6 import DATA_PATH
from mom6.mom6_module.mom6_types import RegionalOptions,GridOptions,DataTypeOptions,DataSourceOptions

warnings.simplefilter("ignore")
xr.set_options(keep_attrs=True)


# typing
RegionalOptions = Literal[
'MAB','GOM','SS','GB','SS_LME','NEUS_LME','SEUS_LME',
'GOMEX','GSL','NGOMEX','SGOMEX','Antilles','Floridian'
]



class OpenDapStore:
"""class to handle the OPeNDAP request
"""
def __init__(
self,
grid : Literal['raw','regrid'] = 'raw',
data_type : Literal['forecast','historical'] = 'historical'
grid : GridOptions = 'raw',
data_type : DataTypeOptions = 'historical'
) -> None:
"""
input for the class to get the opendap data
Expand Down Expand Up @@ -136,8 +129,8 @@ def __init__(
iyear : int,
imonth : int,
var : str,
grid : Literal['raw','regrid'] = 'raw',
source : Literal['local','opendap'] = 'local'
grid : GridOptions = 'raw',
source : DataSourceOptions = 'local'
) -> None:
"""
input for the class to get the individual forecast
Expand Down Expand Up @@ -222,8 +215,8 @@ def get_mom6(self) -> xr.Dataset:
@staticmethod
def get_mom6_all(
var : str,
grid : Literal['raw','regrid'] = 'raw',
source : Literal['local','opendap'] = 'local'
grid : GridOptions = 'raw',
source : DataSourceOptions = 'local'
) -> xr.Dataset:
"""
Return the mom6 all rawgrid/regridded hindcast/forecast field
Expand Down Expand Up @@ -586,8 +579,8 @@ def __init__(
year : int,
month : int,
day : int = 1,
grid : Literal['raw','regrid'] = 'raw',
source : Literal['local','opendap'] = 'local'
grid : GridOptions = 'raw',
source : DataSourceOptions = 'local'
) -> None:
"""
input for getting the historical run data
Expand Down Expand Up @@ -672,8 +665,8 @@ def get_mom6(self) -> xr.Dataset:
@staticmethod
def get_mom6_all(
var : str,
grid : Literal['raw','regrid'] = 'raw',
source : Literal['local','opendap'] = 'local'
grid : GridOptions = 'raw',
source : DataSourceOptions = 'local'
) -> xr.Dataset:
"""
Return the mom6 all rawgrid/regridded historical run field
Expand Down Expand Up @@ -774,7 +767,7 @@ def get_mom6_grid() -> xr.Dataset:
@staticmethod
def get_mom6_mask(
mask : Literal['wet','wet_c','wet_u','wet_v'] = 'wet',
grid : Literal['raw','regrid'] = 'raw'
grid : GridOptions = 'raw'
) -> xr.DataArray:
"""
The function is designed to export the various mask provided
Expand Down
26 changes: 10 additions & 16 deletions mom6/mom6_module/mom6_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,21 @@
import numpy as np
import xarray as xr
from mom6 import DATA_PATH
from mom6.mom6_module.mom6_types import ModelRegionOptions,GridOptions,DataTypeOptions,DataSourceOptions

warnings.simplefilter("ignore")
xr.set_options(keep_attrs=True)


# typing
RegionalOptions = Literal[
'MAB','GOM','SS','GB','SS_LME','NEUS_LME','SEUS_LME',
'GOMEX','GSL','NGOMEX','SGOMEX','Antilles','Floridian'
]



class OpenDapStore:
"""class to handle the OPeNDAP request
"""
def __init__(
self,
region : Literal['northwest_atlantic'] = 'northwest_atlantic',
grid : Literal['raw','regrid'] = 'raw',
data_type : Literal['forecast','historical'] = 'historical'
region : ModelRegionOptions = 'northwest_atlantic',
grid : GridOptions = 'raw',
data_type : DataTypeOptions = 'historical'
) -> None:
"""
input for the class to get the opendap data
Expand Down Expand Up @@ -136,8 +130,8 @@ def __init__(
data_relative_dir : str = None,
static_relative_dir : str = None,
tercile_relative_dir : str = None,
grid : Literal['raw','regrid'] = 'raw',
source : Literal['local','opendap'] = 'local',
grid : GridOptions = 'raw',
source : DataSourceOptions = 'local',
) -> None:
"""
input for the class to get the forecast data
Expand Down Expand Up @@ -219,7 +213,7 @@ def get_all(self) -> xr.Dataset:
chunks=io_chunk
).sortby('init')
ds = xr.merge([ds_static,ds])
# ds = ds.isel(init=slice(1,None)) # exclude the 1980 empty field due to merge
ds = ds.drop_vars(['time']) # a result of merge of ds_static

# test if accident read regrid file
try:
Expand Down Expand Up @@ -324,7 +318,7 @@ def get_tercile(
chunks=io_chunk
).sortby('init')
ds = xr.merge([ds_static,ds])
# ds = ds.isel(init=slice(1,None)) # exclude the 1980 empty field due to merge
ds = ds.drop_vars(['time']) # a result of merge of ds_static

# test if accident read regrid file
try:
Expand Down Expand Up @@ -497,8 +491,8 @@ def __init__(
var : str,
data_relative_dir : str = None,
static_relative_dir : str = None,
grid : Literal['raw','regrid'] = 'raw',
source : Literal['local','opendap'] = 'local',
grid : GridOptions = 'raw',
source : DataSourceOptions = 'local',
) -> None:
"""
input for getting the historical run data
Expand Down
Loading