[ncl-talk] Error with lat and lon corrdinates

Ipshita Majhi ipmajhi at alaska.edu
Mon Nov 21 11:50:12 MST 2016


Dear NCL,

I figured out the lat and lon problem. I was not attaching the coordinates
correctly. I have another problem. When I plot with significance the whole
plot is hatched. I am attaching that plot with this email and the code as
well. I would be grateful if you could guide me on this.
;*******************************************
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"
;*******************************************

;============================================
; set up parameters
;============================================

;********************************************
;This is reading in Snow water equivalent which goes from 0 to 250 mm
; from 1982 to 2012
;********************************************

dira = "/Users/ipshita/Desktop/GlobsnowV2.0/version02/"
dirb = dira + "2011/"
;dira = "./"
;dirb = "./"
a = addfile(dira+"monthly_82_13.nc","r")
b = addfile(dirb+"GlobSnow_SWE_L3A_20110101_v2.0.nc","r")

swe  = a->swe
time = a->time

lat  = b->lat
lon  = b->lon
swe at lat2d = lat
swe at lon2d = lon

print(dimsizes(lat))
print(dimsizes(lon))

swe_FillValue=-9.99e+08

utc_date = cd_calendar(time, 0)
year=utc_date(:,0)
month=utc_date(:,1)

;********************************************
;This is to extract 1982-2012 of swe data
;********************************************
swe_82_12=swe(0:371,:,:)

;********************************************

;********************************************
;This is to read in All India Rainfall
;For March , March , June
;********************************************

MJ_1982_2014=asciiread("~/Documents/NCL_files/SST/Monthly/MJ.txt",(/34,1/),"float")
MJ_1982_2012=MJ_1982_2014(0:30,0)

print(dimsizes(MJ_1982_2012))

;*******************************************
;Extracting monthly data for sce
;*******************************************

March_swe = new((/31,721,721/),float)

March_swe at _FillValue = -9.99e+08

do nyr=0,371,12

March_swe(nyr/12,:,:) =swe_82_12(nyr+2,:,:)

end do
;=================================================
March_swe at _FillValue = -9.99e+08
;**********************************************

March_dt =
dtrend_msg(March_swe&time,March_swe(lat|:,lon|:,time|:),True,False)

printMinMax(March_dt,False)

;****************************************
;Calculating Correlation
;***************************************
x1d=ndtooned(MJ_1982_2012)

corr_March=escorc(March_dt,x1d)
print(dimsizes(corr_March))

corr_March!0="lat"
corr_March!1="lon"

corr_March&lat = swe&lat ; assign coordinate values and
corr_March&lon=swe&lon ; units attributes

copy_VarAtts(swe,corr_March)
copy_VarCoords(swe,corr_March)

corr_March&lat at units = "degrees_north"
corr_March&lon at units = "degrees_east"
;**********************************************
;**********************************************
;Calculating significance
;**********************************************

prob_March=rtest(corr_March,31,0)
sig_March =100*(1-prob_March)
sig_March = mask(sig_March, sig_March.eq.100,False)
sig_March = mask(sig_March, sig_March.le.90,False)

sig_March !0="lat"
sig_March !1="lon"

sig_March&lat = swe&lat ; assign coordinate values and
sig_March&lon=swe&lon ; units attributes

copy_VarAtts(swe,sig_March)
copy_VarCoords(swe,sig_March)

 sig_March&lat at units = "degrees_north"
sig_March&lon at units = "degrees_east"

;**********************************************
;************************************************
; create plot
;************************************************
  wks = gsn_open_wks("pdf","SWE_March_MJ_correlation_significance")
      ;

    res                     = True              ; Plot modes desired.
    res at gsnDraw             = False       ; Do not draw plot
   res at gsnFrame            = False       ; Do not advance frome
    res at gsnMaximize         = True              ; Maximize plot
    res at cnFillOn            = True              ; color plot desired
    res at cnFillPalette       = "BrownBlue12"
    res at cnLinesOn           = False             ; turn off contour lines
    res at pmLabelBarWidthF    = 0.9               ; make wider
    res at pmLabelBarHeightF   = 0.1               ; default is taller
    res at lbLabelFontHeightF  = .018              ; default is HUGE


;*******************************************
; georeferencing: plot on polar projection
;*******************************************
    res at trGridType   = "TriangularMesh"        ; allow missing coordinates
    res at gsnAddCyclic = False
    res at cnFillMode   = "RasterFill"

    res at gsnPolar   = "NH"                          ; specify the hemisphere
    res at mpMinLatF  = 35

    res at tiMMarchainString = "March SWE and MJ correlation"

  plot = gsn_csm_contour_map_polar(wks,corr_March,res)

;**********************************************
;Adding significance plot
;********************************************

;===============================================
;Significance
;================================================
 res1=True
 res1 at gsnDraw             = False       ; Do not draw plot
 res1 at gsnFrame            = False       ; Do not advance frome
 res1 at cnFillOn             = True
 res1 at cnLinesOn           = False                            ; no contour
lines
 res1 at cnMonoFillColor      = True
 res1 at cnMonoFillPattern    = False
 res1 at lbLabelBarOn        = False
 res1 at cnLevelSelectionMode = "ManualLevels"   ; manually specify contour
levels
res1 at cnMinLevelValF       = 90             ; min level
res1 at cnMaxLevelValF       = 100             ; max level
 res1 at cnLevelSpacingF      =  1              ; contour interval
 res1 at gsnSpreadColors      = False
 res1 at cnFillPatterns       =  (/17,17,17,17,17,17,17,17,17,17/)
res1 at cnLineLabelsOn      = False

;  scale   = 1.0
 ; dotsize = 0.005
 ; res at cnFillScaleF   = scale
 ; res at cnFillDotSizeF = dotsize


 plot1 =  gsn_csm_contour(wks,sig_March,res1)

 overlay (plot, plot1)

 draw (plot)
 frame(wks)


;************************************

I get the following warnings

warning:tiMMarchainString is not a valid resource in
SWE_March_MJ_correlation_significance_contour at this time
warning:tiMMarchainString is not a valid resource in ezplot1p_map at this
time
(0) get_lon_values: Warning: The range your of longitude values is greater
than 360.
warning:tmXBMode is not a valid resource in
SWE_March_MJ_correlation_significance_contour.PlotManager at this time
warning:tmXBValues is not a valid resource in
SWE_March_MJ_correlation_significance_contour.PlotManager at this time
warning:tmXBLabels is not a valid resource in
SWE_March_MJ_correlation_significance_contour.PlotManager at this time
warning:tmXBMinorValues is not a valid resource in
SWE_March_MJ_correlation_significance_contour.PlotManager at this time
(0) get_lat_values: Warning: Your latitude values do not fall between -90
and 90 inclusive.
(0) You will not get 'nice' latitude labels.

On Mon, Nov 21, 2016 at 8:56 AM, Rick Brownrigg <brownrig at ucar.edu> wrote:

> Hi,
>
> What do you mean by ".... lat lon dimensions don't show up"?  What do you
> get instead?
>
> I think the reason for the warnings is that you are not plotting on top of
> a map, and thus those resources don't apply.  Perhaps you want to plot
> using gsn_csm_contour_map()  ?
>
> HTH...
> Rick
>
>
> On Sun, Nov 20, 2016 at 5:17 PM, Ipshita Majhi <ipmajhi at alaska.edu> wrote:
>
>> Dear NCL,
>>
>> I am trying to plot SWE data and the lat lon dimensions don't show up.
>> I would be grateful if you could guide me on this
>> *********************************************************
>> ;********************************************
>> ;This is reading in Snow water equivalent which goes from 0 to 250 mm
>> ; from 1982 to 2012
>> ;********************************************
>>
>> dira = "/Users/ipshita/Desktop/GlobsnowV2.0/version02/"
>> dirb = dira + "2011/"
>> ;dira = "./"
>> ;dirb = "./"
>> a = addfile(dira+"monthly_82_13.nc","r")
>> b = addfile(dirb+"GlobSnow_SWE_L3A_20110101_v2.0.nc","r")
>>
>> swe  = a->swe
>> time = a->time
>> lat  = b->lat
>> lon  = b->lon
>> swe at lat2d = lat
>> swe at lon2d = lon
>>
>> print(dimsizes(lat))
>> print(dimsizes(lon))
>>
>> swe_FillValue=-9.99e+08
>>
>> utc_date = cd_calendar(time, 0)
>> year=utc_date(:,0)
>> month=utc_date(:,1)
>>
>> ;********************************************
>> ;This is to extract 1982-2012 of swe data
>> ;********************************************
>> swe_82_12=swe(0:371,:,:)
>>
>> ;********************************************
>>
>> ;********************************************
>> ;This is to read in All India Rainfall
>> ;For March , March , June
>> ;********************************************
>>
>> MJ_1982_2014=asciiread("~/Documents/NCL_files/SST/Monthly/
>> MJ.txt",(/34,1/),"float")
>> MJ_1982_2012=MJ_1982_2014(0:30,0)
>>
>> print(dimsizes(MJ_1982_2012))
>>
>> ;*******************************************
>> ;Extracting monthly data for sce
>> ;*******************************************
>>
>> March_swe = new((/31,721,721/),float)
>>
>> March_swe at _FillValue = -9.99e+08
>>
>> do nyr=0,371,12
>>
>> March_swe(nyr/12,:,:) =swe_82_12(nyr+2,:,:)
>>
>> end do
>> ;=================================================
>> March_swe at _FillValue = -9.99e+08
>> ;**********************************************
>>
>> March_dt = dtrend_msg(March_swe&time,March_swe(lat|:,lon|:,time|:),True
>> ,False)
>>
>> printMinMax(March_dt,False)
>>
>> ;****************************************
>> ;Calculating Correlation
>> ;***************************************
>> x1d=ndtooned(MJ_1982_2012)
>>
>> corr_March=escorc(March_dt,x1d)
>> corr_March!0="lat"
>> corr_March!1="lon"
>> corr_March&lat=lat
>> corr_March&lon=lon
>>
>> copy_VarCoords(swe,corr_March)
>>
>>
>> ;**********************************************
>>
>> ;************************************************
>> ; create plot
>> ;************************************************
>>   wks = gsn_open_wks("x11","SWE_March_MJ_correlation_significance")
>>           ;
>>
>>     res                     = True              ; Plot modes desired.
>>     res at gsnMaximize         = True              ; Maximize plot
>>     res at cnFillOn            = True              ; color plot desired
>>     res at cnFillPalette       = "BrownBlue12"
>>     res at cnLinesOn           = False             ; turn off contour lines
>>     res at pmLabelBarWidthF    = 0.9               ; make wider
>>     res at pmLabelBarHeightF   = 0.1               ; default is taller
>>     res at lbLabelFontHeightF  = .018              ; default is HUGE
>>
>>
>> ;*******************************************
>> ; georeferencing: plot on polar projection
>> ;*******************************************
>>     res at trGridType   = "TriangularMesh"        ; allow missing
>> coordinates
>>     res at gsnAddCyclic = False
>>     res at cnFillMode   = "RasterFill"
>>
>>     res at gsnPolar   = "NH"                          ; specify the
>> hemisphere
>>     res at mpMinLatF  = 35
>>
>>     res at tiMainString = "March SWE and MJ correlation"
>>
>>   plot = gsn_csm_contour(wks,corr_March,res)
>>
>> ;*******************************************************
>>
>> warning:gsnPolar is not a valid resource in SWE_March_MJ_correlation_significance_contour
>> at this time
>> warning:mpMinLatF is not a valid resource in
>> SWE_March_MJ_correlation_significance_contour at this time
>>
>>
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>


-- 
Ipshita Majhi
PhD Candidate
University of Alaska , Fairbanks
Atmospheric Science Department
(907)978-4220 ipmajhi at alaska.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20161121/c0a95803/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SWE_March_MJ_correlation_significance.pdf
Type: application/pdf
Size: 158251 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20161121/c0a95803/attachment-0001.pdf 


More information about the ncl-talk mailing list