Project

General

Profile

creating a sea land mask for precipitation data with zeros

Added by Tarek AM 8 months ago

Hi,

I am trying to use a sea land mask for precipitation dataset that includes zeros. My mask has the value 0 for sea and 1 for land. I tried setting the zeros to miss using -setctomiss,0 infile.nc outfile.nc but that doesn't appear to change anything. I wonder why that is? I attached the file in case anyone might be able to figure it out. Any other workaround to do this properly also?

Thanks in advance.
Tarek


Replies (4)

RE: creating a sea land mask for precipitation data with zeros - Added by Karin Meier-Fleischer 8 months ago

Hi Tarek,
the land sea mask file already has the missing value set to zero (type unsigned short). The following example demonstrates how to use your lsm file.

Example: Generate the global topography data, remap to same grid as the land sea mask, and multiply it with the land sea mask

cdo -f nc -mul land10km_wgs84_con.nc -remapbil,land10km_wgs84_con.nc -topo outfile.nc

RE: creating a sea land mask for precipitation data with zeros - Added by Tarek AM 8 months ago

Hi Karin,

Thanks for the swift response. Yes, the missing values are set to zero type ubyte. I want to change the variable data type to float and assign miss value to e.g., -9999 to avoid clipping my map that already has zeros as data (0 precipitation at a given location at a given timestep). This is how it looks like (please see attached).

Best regards,
Tarek

RE: creating a sea land mask for precipitation data with zeros - Added by Karin Meier-Fleischer 8 months ago

Try

cdo -b f32 -setmissval,-9999. -setmisstoc,-9999. land10km_wgs84_con.nc lsm.nc

RE: creating a sea land mask for precipitation data with zeros - Added by Tarek AM 8 months ago

Hi again,

Thanks Karin, I arrived at the same result at the same time, which I ended up using. However, this was a bit more problematic for another set of data that already has a sea land mask. So, I resorted to first applying the lsm.nc mask to the data which gave me a lot of 0 values beyond the land (i.e., the ocean), and then divided the data itself by another mask with miss value = 0, which removed the zeros from the ocean only using

cdo div data_file.nc lsm_zeros.nc outfile_masked.nc

I mention this in case some has encountered a similar issue dealing with already masked data.

Again, thanks for the help and quick responses.

Best regards,
Tarek

    (1-4/4)