@@ -1950,6 +1950,7 @@ def write_netcdf_chemical_density_map(self, filename, pixelsize_m='auto', zlevel
19501950 smoothing_cells = 0 ,
19511951 reader_sea_depth = None ,
19521952 landmask_shapefile = None ,
1953+ landmask_bathymetry_thr = None ,
19531954 origin_marker = None ,
19541955 elements_density = False ,
19551956 active_status = False ,
@@ -1977,6 +1978,7 @@ def write_netcdf_chemical_density_map(self, filename, pixelsize_m='auto', zlevel
19771978 smoothing_cells: int, number of cells for horizontal smoothing,
19781979 reader_sea_depth: string, path of bathimethy .nc file,
19791980 landmask_shapefile: string, path of bathimethylandmask .shp file
1981+ landmask_bathymetry_thr: float32, if set the value is the threshold used to extract the landmask from reader_sea_depth
19801982 elements_density: boolean, add number of elements present in each grid cell to output
19811983 origin_marker: int, only elements with this value of "origin_marker" will be considered
19821984 active_status: boolean, only active elements will be considered
@@ -2205,7 +2207,13 @@ def is_valid_proj4(density_proj):
22052207 lat_array = (lat_array [:- 1 ,:- 1 ] + lat_array [1 :,1 :])/ 2
22062208
22072209 landmask = np .zeros_like (H [0 ,0 ,0 ,:,:])
2208- if landmask_shapefile is not None :
2210+ if (landmask_bathymetry_thr is not None ) and (reader_sea_depth is not None ):
2211+ landmask = reader_sea_depth .get_variables_interpolated_xy (['sea_floor_depth_below_sea_level' ],
2212+ x = np .clip (lon_array .flatten (),reader_sea_depth .xmin ,reader_sea_depth .xmax ),
2213+ y = np .clip (lat_array .flatten (),reader_sea_depth .ymin ,reader_sea_depth .ymax ),
2214+ time = reader_sea_depth .times [0 ] if reader_sea_depth .times is not None else None
2215+ )[0 ]['sea_floor_depth_below_sea_level' ] <= landmask_bathymetry_thr #.reshape(self.conc_lon.shape)
2216+ elif landmask_shapefile is not None :
22092217 landmask = self .env .readers ['shape' ].get_variables ('land_binary_mask' , x = lon_array ,y = lat_array )['land_binary_mask' ]
22102218 else :
22112219 landmask = self .env .readers ['global_landmask' ].get_variables ('land_binary_mask' , x = lon_array ,y = lat_array )['land_binary_mask' ]
0 commit comments