In general, you always want to unpack a short value.
Note the scale_factor and add_offset. These are netCDF
convention attributes, specifically COARDS and CF.
See:  http://www.ncl.ucar.edu/Document/Functions/Contributed/short2flt.shtml
The _FillValue should pertain to the short variable. It will
be carried over to type float in this case.
       aor = short2flt( a->Optical_Depth_Land_And_Ocean )
       printVarSummary( aor )
       printMinMax( aor, True)
Walter R Sessions wrote:
> Thanks for the quick response,
>
>   Plotting the raw data values hasn't been a problem; the lat2d/lon2d
> worked perfectly for that.  
>
>   As for the gridding, I've attached a copy of the printVarSummary for
> aodr.  It does contain the _FillValue attribute straight from the file,
> but it is -9999.  Should that be -99 since the variable is of type
> 'short'?  Does cssgrid have problems with short?
>
>   Also pertaining to the variable type, the poisson function wanted a
> float or double variable.
>
> Walter
>
> printVarSummary(aodr) [raw data]
> **************************************************************************
> Variable: aodr
> Type: short
> Total Size: 54810 bytes
>             27405 values
> Number of Dimensions: 2
> Dimensions and sizes:   [Cell_Along_Swath_mod04 | 203] x
> [Cell_Across_Swath_mod04 | 135]
> Coordinates: 
> Number Of Attributes: 11
>   _FillValue :  -9999
>   valid_range : ( -100, 5000 )
>   long_name :   AOT at 0.55 micron for both ocean (best) and land
> (corrected)  with best quality data(Quality flag=3)
>   units :       None
>   scale_factor :        0.001000000047497451
>   add_offset :     0
>   Parameter_Type :      Output
>   Cell_Along_Swath_Sampling :   ( 5, 2025, 10 )
>   Cell_Across_Swath_Sampling :  ( 5, 1345, 10 )
>   Geolocation_Pointer : Internal geolocation arrays
>   hdf_name :    Optical_Depth_Land_And_Ocean
> ************************************************************************
> On Sat, 2008-04-19 at 08:24 -0600, Dennis Shea wrote:
>   
>> 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 - 11:57:36 MDT
This archive was generated by hypermail 2.2.0 : Sun Apr 20 2008 - 07:42:42 MDT