@@ -15,6 +15,7 @@ class InputData:
1515 adcp_fieldset : FieldSet | None
1616 argo_float_fieldset : FieldSet | None
1717 ctd_fieldset : FieldSet | None
18+ ctd_bgc_fieldset : FieldSet | None
1819 drifter_fieldset : FieldSet | None
1920 xbt_fieldset : FieldSet | None
2021 ship_underwater_st_fieldset : FieldSet | None
@@ -26,6 +27,7 @@ def load(
2627 load_adcp : bool ,
2728 load_argo_float : bool ,
2829 load_ctd : bool ,
30+ load_ctd_bgc : bool ,
2931 load_drifter : bool ,
3032 load_xbt : bool ,
3133 load_ship_underwater_st : bool ,
@@ -39,6 +41,7 @@ def load(
3941 :param load_adcp: Whether to load the ADCP fieldset.
4042 :param load_argo_float: Whether to load the argo float fieldset.
4143 :param load_ctd: Whether to load the CTD fieldset.
44+ :param load_ctd_bgc: Whether to load the CTD BGC fieldset.
4245 :param load_drifter: Whether to load the drifter fieldset.
4346 :param load_ship_underwater_st: Whether to load the ship underwater ST fieldset.
4447 :returns: An instance of this class with loaded fieldsets.
@@ -51,6 +54,10 @@ def load(
5154 argo_float_fieldset = cls ._load_argo_float_fieldset (directory )
5255 else :
5356 argo_float_fieldset = None
57+ if load_ctd_bgc :
58+ ctd_bgc_fieldset = cls ._load_ctd_bgc_fieldset (directory )
59+ else :
60+ ctd_bgc_fieldset = None
5461 if load_adcp or load_ctd or load_ship_underwater_st or load_xbt :
5562 ship_fieldset = cls ._load_ship_fieldset (directory )
5663 if load_adcp :
@@ -74,6 +81,7 @@ def load(
7481 adcp_fieldset = adcp_fieldset ,
7582 argo_float_fieldset = argo_float_fieldset ,
7683 ctd_fieldset = ctd_fieldset ,
84+ ctd_bgc_fieldset = ctd_bgc_fieldset ,
7785 drifter_fieldset = drifter_fieldset ,
7886 xbt_fieldset = xbt_fieldset ,
7987 ship_underwater_st_fieldset = ship_underwater_st_fieldset ,
@@ -122,6 +130,48 @@ def _load_ship_fieldset(cls, directory: Path) -> FieldSet:
122130
123131 return fieldset
124132
133+ @classmethod
134+ def _load_ctd_bgc_fieldset (cls , directory : Path ) -> FieldSet :
135+ filenames = {
136+ "U" : directory .joinpath ("ship_uv.nc" ),
137+ "V" : directory .joinpath ("ship_uv.nc" ),
138+ "o2" : directory .joinpath ("ctd_bgc_o2.nc" ),
139+ "chl" : directory .joinpath ("ctd_bgc_chloro.nc" ),
140+ }
141+ variables = {"U" : "uo" , "V" : "vo" , "o2" : "o2" , "chl" : "chl" }
142+ dimensions = {
143+ "lon" : "longitude" ,
144+ "lat" : "latitude" ,
145+ "time" : "time" ,
146+ "depth" : "depth" ,
147+ }
148+
149+ fieldset = FieldSet .from_netcdf (
150+ filenames , variables , dimensions , allow_time_extrapolation = True
151+ )
152+ fieldset .o2 .interp_method = "linear_invdist_land_tracer"
153+ fieldset .chl .interp_method = "linear_invdist_land_tracer"
154+
155+ # make depth negative
156+ for g in fieldset .gridset .grids :
157+ g .negate_depth ()
158+
159+ # add bathymetry data
160+ bathymetry_file = directory .joinpath ("bathymetry.nc" )
161+ bathymetry_variables = ("bathymetry" , "deptho" )
162+ bathymetry_dimensions = {"lon" : "longitude" , "lat" : "latitude" }
163+ bathymetry_field = Field .from_netcdf (
164+ bathymetry_file , bathymetry_variables , bathymetry_dimensions
165+ )
166+ # make depth negative
167+ bathymetry_field .data = - bathymetry_field .data
168+ fieldset .add_field (bathymetry_field )
169+
170+ # read in data already
171+ fieldset .computeTimeChunk (0 , 1 )
172+
173+ return fieldset
174+
125175 @classmethod
126176 def _load_drifter_fieldset (cls , directory : Path ) -> FieldSet :
127177 filenames = {
0 commit comments