Re: about lat and lon

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed Jul 28 2010 - 14:15:54 MDT

Yi,

Please see example hdf4eos_5.ncl at:

http://www.ncl.ucar.edu/Applications/HDF.shtml

The key is setting these resources:

  res@cnLevelSelectionMode = "ManualLevels" ; set manual contour levels
  res@cnMinLevelValF = 1 ; set min contour level
  res@cnMaxLevelValF = 3 ; one less than max
  res@cnLevelSpacingF = 1 ; set contour spacing

  res@lbLabelStrings = ispan(0,3,1) ; 0, 1, 2, 3
  res@lbLabelPosition = "Center" ; label position
  res@lbLabelAlignment = "BoxCenters"
Of course, you will need to change the values to fit your data.

--Mary

On Jul 28, 2010, at 2:12 PM, Yi Wang wrote:

> Hi Adam and Mary,
>
> Thanks a lot. Let me check those latitudes/longitudes again. And now I have another question for you.
> The corresponding HDF file is here: ftp://ftp.hdfgroup.uiuc.edu/pub/outgoing/NASAHDF/MOD10_L2.A2000065.0040.005.2008235221207.hdf
>
> My NCL file is MOD10_L2.A2000065.0040.005.2008235221207_Fractional_Snow_Cover.ncl (see attachment).
>
> My question is: in the color bar, can I generate exactly two colors, each of which corresponding to one value in Fractional_Snow_Cover's value table (If you open the HDF file, and see the values in Fractional_Snow_Cover field, you will find there are only two different values). Thank you!
>
> Best,
> Yi
>
>
>
>
> On Wed, Jul 28, 2010 at 1:36 PM, Adam Phillips <asphilli@ucar.edu> wrote:
> Hi Yi,
> Mary suggested offline to me that you set gsnAddCyclic to False because
> you have 2D lats/lons, but I see you are already doing that. The other
> way you can get this error is if the number of 2D latitude/longitude
> points do not match the number of grid points from your data array,
> which is something I queried you about yesterday. Please check to make
> sure you are using the correct latitudes/longitudes, and that the number
> of 2D lat (lon) points equals the number of grid points in your data
> array...
> Best regards,
> Adam
>
> On 07/28/2010 11:02 AM, Yi Wang wrote:
> > Hi Adam and Mary,
> > Thanks you so much. Attached is my new codes. But I still got some error
> > messages:
> > warning:ScalarFieldSetValues: coordinate array sfXArray requires
> > 153330195 elements: defaulting
> > warning:ScalarFieldSetValues: coordinate array sfYArray requires
> > 153330204 elements: defaulting
> > fatal:ContourPlotDraw: Workspace reallocation would exceed maximum size
> > 32556688
> > fatal:ContourPlotDraw: draw error
> > warning:WorkstationDeactivate: workstation not active or not opened
> > Thanks.
> > Best,
> > Yi
> >
> >
> > On Wed, Jul 28, 2010 at 7:15 AM, Mary Haley <haley@ucar.edu
> > <mailto:haley@ucar.edu>> wrote:
> >
> > Hi Yi,
> >
> > These look like pretty simple ASCII files, so you should be able to
> > read them with:
> >
> > lat =
> > asciiread("lat_MYD02HKM.A2010031.0035.005.2010031183706.output
> > ",-1,"float")
> > lon =
> > asciiread("lon_MYD02HKM.A2010031.0035.005.2010031183706.output",-1,"float")
> >
> > The second "-1" argument will cause the lat/lon values to be read
> > into one-dimensional arrays.
> > If your data is one-dimensional, and the same length as these
> > lat/lon arrays, then you will further
> > need to set the sfXArray and sfYArray resources, so the data is
> > overlaid correctly on the map:
> >
> > res@sfXArray = lon
> > res@sfYArray = lat
> >
> >
> > If "data" is two-dimensional, and lat/lon are supposed to be as
> > well, then your code might look something like this:
> >
> > lat = asciiread("lat_MYD02HKM.A2010031.0035.005.2010031183706.output
> > ", \
> > (/nlat,nlon/),"float")
> > lon = asciiread("lon_MYD02HKM.A2010031.0035.005.2010031183706.output", \
> > (/nlat,nlon/),"float")
> >
> > You will still need to set sfXArray and sfYArray as above. In both
> > cases, you might also want to set:
> >
> > res@gsnAddCyclic = False
> >
> > --Mary
> >
> > On Jul 27, 2010, at 12:31 PM, Yi Wang wrote:
> >
> >> Hi Friends,
> >> Could you please tell me how to get lat and lon from
> >> lat_MYD02HKM.A2010031.0035.005.2010031183706.output
> >> (ftp://ftp.hdfgroup.uiuc.edu/pub/outgoing/NASAHDF/lat_MYD02HKM.A2010031.0035.005.2010031183706.output) and
> >> lon_MYD02HKM.A2010031.0035.005.2010031183706.output
> >> (ftp://ftp.hdfgroup.uiuc.edu/pub/outgoing/NASAHDF/lon_MYD02HKM.A2010031.0035.005.2010031183706.output)
> >> ?
> >> My ncl codes is in
> >> MYD02HKM.A2010031.0035.005.2010031183706_EV_500_RefSB.ncl (see
> >> attachment), and the corresponding HDF file can be found here:
> >> ftp://ftp.hdfgroup.uiuc.edu/pub/outgoing/NASAHDF/MYD02HKM.A2010031.0035.005.2010031183706.hdf
> >>
> >> Thanks a lot.
> >> Best,
> >> Yi Wang
> >> <MYD02HKM.A2010031.0035.005.2010031183706_EV_500_RefSB.ncl>_______________________________________________
> >>
> >>
> >> ncl-talk mailing list
> >> List instructions, subscriber options, unsubscribe:
> >> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >
> >
> >
> >
> > _______________________________________________
> > ncl-talk mailing list
> > List instructions, subscriber options, unsubscribe:
> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
> --
> __________________________________________________
> Adam Phillips
> asphilli@ucar.edu
> National Center for Atmospheric Research tel: (303) 497-1726
> Climate and Global Dynamics Division fax: (303) 497-1333
> P.O. Box 3000
> Boulder, CO 80307-3000 http://www.cgd.ucar.edu/cas/asphilli
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
> <MOD10_L2.A2000065.0040.005.2008235221207_Fractional_Snow_Cover.ncl>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Jul 28 14:16:01 2010

This archive was generated by hypermail 2.1.8 : Fri Jul 30 2010 - 13:45:56 MDT