Search code examples
netcdfnetcdf4nco

Masking data over land/including only oceanic data using NCO?


I have two different datasets, which originally had different resolutions but have been regridded using CDO's remapbil operator to have 0.1x0.1 degree resolution. The first is NASA's MERRA-2 planetary boundary layer height (PBLH) data and the second is NASA's IMERG rain rate (precipitationCal below) data. I have referenced this question about masking oceanic data, but I still am a bit confused as to where to start. I am trying to mask land data instead of oceanic data. How do I go about creating my own mask for my data? The descriptions of the data are shown below.

dimensions:
        time = UNLIMITED ; // (24 currently)
        lon = 650 ;
        lat = 351 ;
variables:
        int time(time) ;
                time:standard_name = "time" ;
                time:long_name = "time" ;
                time:units = "minutes since 2020-07-13 00:30:00" ;
                time:calendar = "standard" ;
                time:axis = "T" ;
        float lon(lon) ;
                lon:standard_name = "longitude" ;
                lon:long_name = "longitude" ;
                lon:units = "degrees_east" ;
                lon:axis = "X" ;
        float lat(lat) ;
                lat:standard_name = "latitude" ;
                lat:long_name = "latitude" ;
                lat:units = "degrees_north" ;
                lat:axis = "Y" ;
        float PBLH(time, lat, lon) ;
                PBLH:standard_name = "planetary_boundary_layer_height" ;
                PBLH:long_name = "planetary_boundary_layer_height" ;
                PBLH:units = "m" ;
                PBLH:_FillValue = 1.e+15f ;
                PBLH:missing_value = 1.e+15f ;
                PBLH:fmissing_value = 1.e+15f ;
                PBLH:vmax = 1.e+15f ;
                PBLH:vmin = -1.e+15f ;
                PBLH:origname = "PBLH" ;
                PBLH:fullnamepath = "/PBLH" ;

dimensions:
        time = 1 ;
        lon = 650 ;
        lat = 351 ;
        latv = 2 ;
        nv = 2 ;
        lonv = 2 ;
int time(time) ;
                time:DimensionNames = "time" ;
                time:Units = "seconds since 1970-01-01 00:00:00 UTC" ;
                time:units = "seconds since 1970-01-01 00:00:00 UTC" ;
                time:standard_name = "time" ;
                time:LongName = "Representative time of data in \n",
                        "\t\t\tseconds since 1970-01-01 00:00:00 UTC." ;
                time:bounds = "time_bnds" ;
                time:axis = "T" ;
                time:calendar = "julian" ;
                time:origname = "time" ;
                time:fullnamepath = "/Grid/time" ;
float lon(lon) ;
                lon:DimensionNames = "lon" ;
                lon:Units = "degrees_east" ;
                lon:units = "degrees_east" ;
                lon:standard_name = "longitude" ;
                lon:LongName = "Longitude at the center of\n",
                        "\t\t\t0.10 degree grid intervals of longitude \n",
                        "\t\t\tfrom -180 to 180." ;
                lon:bounds = "lon_bnds" ;
                lon:axis = "X" ;
                lon:origname = "lon" ;
                lon:fullnamepath = "/Grid/lon" ;
float lat(lat) ;
                lat:DimensionNames = "lat" ;
                lat:Units = "degrees_north" ;
                lat:units = "degrees_north" ;
                lat:standard_name = "latitude" ;
                lat:LongName = "Latitude at the center of\n",
                        "\t\t\t0.10 degree grid intervals of latitude\n",
                        "\t\t\tfrom -90 to 90." ;
                lat:bounds = "lat_bnds" ;
                lat:axis = "Y" ;
                lat:origname = "lat" ;
                lat:fullnamepath = "/Grid/lat" ;
float precipitationCal(time, lon, lat) ;
                precipitationCal:DimensionNames = "time,lon,lat" ;
                precipitationCal:Units = "mm/hr" ;
                precipitationCal:units = "mm/hr" ;
                precipitationCal:coordinates = "time lon lat" ;
                precipitationCal:_FillValue = -9999.9f ;
                precipitationCal:CodeMissingValue = "-9999.9" ;
                precipitationCal:origname = "precipitationCal" ;
                precipitationCal:fullnamepath = "/Grid/precipitationCal" ;

Thank you in advance to anyone who has any insight or suggestions on this.


Solution

  • I was able to figure this out relatively easily following this guide here

    Below is an example of a figure from my data that shows the mask working:

    Masked data