Re: Regridding and Plotting Satellite Data

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Sat, 19 Apr 2008 08:24:14 -0600

Hello

[1]
    The following is one example of directly plotting 'swath' data
    http://www.ncl.ucar.edu/Applications/eosdis.shtml
    See Examples 4 and 5

[2]
      NCL has two reserved attribute names "lat2d" and "lon2d".
      These are used when the data are 'curvilinear'. Basically,
      whenever the data have 2D lat/lon arrays, the variable being
      plotted should have the lat2d/lon2d arrays associated with it

      lat2 = f->Latitude
      lon2 = f->Longitude
      aodr_at_lat2d = lat2 ; associate [assign] the 2d lat/lon
      aodr_at_lon2d = lon2 ; to the variable to be plotted

[3]
     The cssgrid is supposed to ignore missing values [_FillValue].
     Since this is a NASA generated hdf file, I'd be surprised
     if they automatically created the _FillValue attribute. Typically,
     NASA/HDF are blissfully ignorant of *netCDF* conventions.
     WHat does the 'printVarSummary' say. Is there an _FillValue
     attribute? If not, you can manually assign
               aodr@_FillValue = -9999

[4]
    Just for 'fun' try
              poisson_grid_fill( aodr, False, 1, 1500, 1e-2, 0.6, 0)

    plot the aodr in the swath region

Good luck

Walter R Sessions wrote:
> Hello,
>
> I'm attempting to regrid MODIS satellite data for a correlation study
> and have been having difficulty getting it worked out.
>
> Since it is satellite data and there will be missing values, I followed
> the regridding flow chart and have been trying to use the cssgrid
> function. However, I've been running into the following problems.
>
> First, unless I drop the _FillValues, it appears to interpolate to them
> (in this case, -9999). The values of the contoured scalar are wholly
> positive, however the contour of the cssgrid derived plot is goes down
> to the -7e+06 and up into the positive millions.
>
> Second, I've been attempting to just plot a section of a swath in the
> North Pacific, which is all this file contains. The points where it
> does put data appear to be stretching from the appropriate area, south
> of Alaska, down past the equator.
>
> I've attached the script for reference.
>
> It occurs to me that it might be better to attempt to just use an
> average for the value within a defined grid spacing, but I've been
> having difficulty in finding how to do that within NCL.
>
> Advice on either how to average into a grid or to work with cssgrid is
> appreciated.
>
> Walter
>
>
> I've attempted several variations of resources on and off and still
> can't get anything that looks accurate.
>
> ;*************************************************
> ; plot_AOD.ncl
> ;************************************************
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>
>
> begin
> ;-open file and create pointer
> a =
> addfile("./MYD04_L2.A2008031.2300.005.2008033054757.pscs_000500293068.hdf","r")
>
> ;
> ;-input array od data (203x135ish)
> aodr = a->Optical_Depth_Land_And_Ocean
> printVarSummary(aodr)
>
> ;
> ;-get array of lat/lon coordinates
> latr = a->Latitude
> lonr = a->Longitude
>
> ;
> ;-put them both in 1D arrays
> aod1= ndtooned(aodr)
> lat1= ndtooned(latr)
> lon1= ndtooned(lonr)
> print("LAT_MAX: "+dim_max(lat1))
> print("LAT_MIN: "+dim_min(lat1))
> print("LON_MAX: "+dim_max(lon1))
> print("LON_MIN: "+dim_min(lon1))
> print("AOD_MAX: "+dim_max(aod1))
> print("AOD_MIN: "+dim_min(aod1))
>
> ;
> ;-just testing set - should always have missing data
> if(any(ismissing(aod1))) then
> print("MISSING AOD DATA")
> else
> print("No missing data")
> end if
>
> ;
> ;-generate output grid (half degree global)
> ; plon = fspan(-180,180,361)
> ; plat = fspan(-90,90,181)
> plon = fspan(-180,180,181)
> plat = fspan(-90,90,91)
> plon_at_units = "degrees east"
> plat_at_units = "degrees north"
> ;
> ;-future filtering placeholder
> aod_filter = aod1
>
> ;
> ;-grid data onto platxplon
> print("AOD_ONE_DIM : "+dim_max(aod1))
> aod_grid = cssgrid(lat1,lon1,aod_filter,plat,plon)
>
> ; aod_grid!0 = "lat"
> ; aod_grid!1 = "lon"
> ; aod_grid&lat = plat
> ; aod_grid&lon = plon
>
> ;-keep for reference
> ; aod_filter!0 = "lat"
> ; aod_filter!1 = "lon"
> ; aod_filter&lat= plat
> ; aod_filter&lon= plon
> ; aod_filter&lon_at_units = "degrees east"
> ; aod_filter&lat_at_units = "degrees north"
>
> aod_grid!0 = "lat"
> aod_grid!1 = "lon"
> aod_grid&lat = plat
> aod_grid&lon = plon
> aod_grid&lon_at_units = "degrees east"
> aod_grid&lat_at_units = "degrees north"
>
> ;
> ;-create workstation and define colormap
> wks = gsn_open_wks("x11" ,"ce")
> ;-gsn_define_colormap(wks,"WhBlGrYeRe")
> gsn_define_colormap(wks,"testcmap")
>
> ;
> ;-Turn on plotting options then set them
> res = True ; plot mods desired
>
> res_at_cnFillOn = True ; turn on color fill
> ;-res_at_cnFillMode = "RasterFill" ; rasterize plot
> res_at_cnLinesOn = False ; turn of contour lines
> ;-res_at_cnLevelSpacingF = 0.5 ; contour spacing
> res_at_gsnSpreadColors = True ; use full range of color map
> res_at_lbLabelStride = 4
> ;-res_at_pmTickMarkDisplayMode = "Always"; use NCL default lat/lon labels
> ;
> res_at_gsnAddCyclic = False
> res_at_mpMinLatF = -90 ; range to zoom in on
> res_at_mpMaxLatF = 90.
> res_at_mpMinLonF = -180.
> res_at_mpMaxLonF = 180.
>
> ;
> ;-1d monotonic arrays that represent the x/y axes
> ; res_at_sfXArray = plon
> ; res_at_sfYArray = plat
>
> ;-plot = gsn_csm_contour_map(wks,aod_grid, res)
> plot = gsn_csm_contour_map_ce(wks,aod_grid, res)
> end
>
> 113,1 Bot
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Sat Apr 19 2008 - 08:24:14 MDT

This archive was generated by hypermail 2.2.0 : Sun Apr 20 2008 - 07:42:42 MDT