Re: Setting contour levels using a min/max contour level and a spacing

From: <ziying-li_at_nyahnyahspammersnyahnyah>
Date: Thu Sep 16 2010 - 16:38:41 MDT

Hi Mary,
Yes, only 2 values(0 and 39) were contained in this data field. I followed
that example and generate reasonable plot.

But I may have another question that If I want more values in label in
this case. What I should do? I mean only 2 valid values in data (such as 0
and 1), but I not only want to show 0 and 1 represent what, but also 2, 3
and 4 represent what specifically in the label.

Thanks for your prompt reply every time.

Lizzie

> Hi,
>
> Without knowing what your data values are, I'm not sure what the reason is
> behind the lack of red in your plot.
>
> You should print out the min/max of your data to make sure the values are
> what you expect:
>
> print("min/max data = " + min(data) + "/" + max(data))
>
> When you select contour levels of 0 and 39, with the colors red and green
> for these two levels, then what this means is:
>
> values < 0 will be red
> values >= 0 and < 39 will be green
>
> Since you have a third box that is green, then this means anything >= 39
> will be green.
>
> Is this what you intended?
>
> You might want to see example "vegland_1.ncl" at
> http://www.ncl.ucar.edu/Applications/classification.shtml
> for a sample of setting a color bar with just two values.
>
> --Mary
>
> On Sep 16, 2010, at 12:51 PM, ziying-li@hdfgroup.org wrote:
>
>> Mary,
>>
>> I follow your instruction for below case and got corresponding plot as
>> attached.
>>
>> http://www.ncl.ucar.edu/Support/talk_archives/2010/1903.html
>>
>> I checked the latitude for this file and the location should be right.
>> But
>> I'm not sure why '0' can not be plotted.
>>
>> Do you know the reason behind it?
>>
>> Code:
>> ----------------------------------------------------------------------------
>>
>> load "$NCARG_ROOT/lib/ncarg/nclex/gsun/gsn_code.ncl"
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>>
>> begin
>> eos_file=addfile("MOD10_L2.A2000065.0040.005.2008235221207.hdf.he2",
>> "r")
>> ; Read file.
>> ;To read HDF-EOS2 files, .he2 is appended to the argument.
>> ;For more information, consult section 4.3.2 of
>> http://hdfeos.org/software/ncl.php.
>>
>> data_byte=eos_file->Snow_Cover_MOD_Swath_Snow
>> ; read data field, getting the clues about
>> eos_file->Fractional_Snow_Cover_MOD_Swath_Snow
>> ; from print(eos_file)
>>
>> data=byte2flt(data_byte)
>> data@_FillValue = 255b
>>
>> nlon=4060
>> nlat=2708
>>
>> lat=asciiread("lat_MOD10_L2.A2000065.0040.005.2008235221207.output",(/nlon,nlat/),"float")
>> lon=asciiread("lon_MOD10_L2.A2000065.0040.005.2008235221207.output",(/nlon,nlat/),"float")
>>
>> data@lat2d=lat
>> data@lon2d=lon
>>
>> xwks=gsn_open_wks("pdf","MOD10_L2.A2000065.0040.005.2008235221207_Snow_Cover.ncl")
>> colors=(/"white","black","red","green"/)
>> gsn_define_colormap(xwks,colors)
>>
>> setvalues NhlGetWorkspaceObjectId() ; make maximum filesize larger
>> "wsMaximumSize" : 200000000
>> end setvalues
>>
>> res=True
>> res@cnFillOn=True
>> res@gsnMaximize=True
>> res@gsnPaperOrientation = "portrait"
>> res@cnLinesOn=False
>> res@cnLineLabelsOn = False
>> res@gsnSpreadColors=True
>> res@cnFillMode="RasterFill"
>> res@cnMissingValFillPattern = 0 ; missing value pattern is set to
>> "SolidFill"
>> res@cnMissingValFillColor=0; white color for missing values
>>
>> res@cnLevelSelectionMode="ManualLevels"
>> res@cnMinLevelValF=0
>> res@cnMaxLevelValF=39
>> res@cnLevelSpacingF=39
>>
>> res@lbLabelStrings = ispan(0,39,39)
>> res@lbLabelPosition = "Center"
>> res@lbLabelAlignment = "BoxCenters"
>>
>> plot=gsn_csm_contour_map_ce(xwks,data,res)
>>
>> delete(plot) ; cleaning up resources used
>> delete(data)
>>
>> delete(res)
>>
>> delete(eos_file)
>> end<MOD10_L2.A2000065.0040.005.2008235221207Snow_Cover.JPG>_______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
Received on Thu Sep 16 16:38:56 2010

This archive was generated by hypermail 2.1.8 : Mon Sep 20 2010 - 15:45:07 MDT