Re: Error when plotting contour without map

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Tue, 13 May 2008 10:01:21 -0600

Hi Louis,

I cut out the netCDF writing part of your first script and merged your
two scripts, and it worked. So I figured the error must be in the netCDF
file creation process from your original script. Taking a closer look at
that part of your first script, I see that there is a misspelling:

fout->temeparture = (/xtemp/)
I changed that to temperature and your two scripts worked. The reason it
failed was that temperature is a coordinate variable of your FC array,
and it was not being written to the file named as temperature.

So you know, as you are writing a bunch of smaller netCDF files, I think
it would be fine for you to use the alternative netCDF write method. The
only time I don't use this method is when I am writing large netCDF
files or ones with many variables. Your netCDF write code could be
shortened to this:

diro = "./" ; Output directory
filo = name+".nc" ; Output file
system("/bin/rm -f " + diro + filo) ; remove if exists
fout = addfile (diro + filo, "c") ; open output file
filedimdef(fout,"time",-1,True) ; make time an UNLIMITED dimension.
fout->temperature = xtemp ; ( above line is recommended)
fout->FC = dummy_data

Hope that helps,
Adam

louis Vonder wrote:
> Ncl Users,
>
> I get the following errors when I am trying to make a contour plot
> without map.
>
> Copyright (C) 1995-2007 - All Rights Reserved
> University Corporation for Atmospheric Research
> NCAR Command Language Version 5.0.0
> The use of this software is governed by a License Agreement.
> See http://www.ncl.ucar.edu/ for more details.
> avondou_at_berbench:/media/Shared/WA_meteosat/tout/all$
> avondou_at_berbench:/media/Shared/WA_meteosat/tout/all$ ncl contour_shaded.ncl
> Copyright (C) 1995-2007 - All Rights Reserved
> University Corporation for Atmospheric Research
> NCAR Command Language Version 5.0.0
> The use of this software is governed by a License Agreement.
> See http://www.ncl.ucar.edu/ for more details.
> warning:ContourPlotInitialize: Y coordinates out of data range: defaulting
> warning:ContourPlotInitialize: Zero Y coordinate span:
> defaulting:[errno=1104]
> warning:ContourPlotInitialize: current transformation requires trYMinF
> to be within data coordinate range: resetting
> warning:TransInitialize: min Y coordinate exceeds max: exchanging
> warning:IrTransInitialize: trYCoordPoints contains invalid coordinate
> array: defaulting trYAxisType to LinearAxis
> warning:ContourPlotSetValues: Y coordinates out of data range: defaulting
> warning:ContourPlotSetValues: Zero Y coordinate span:
> defaulting:[errno=1104]
> warning:ContourPlotSetValues: current transformation requires trYMinF to
> be within data coordinate range: resetting
> fatal:TickMark:CheckIrregular: Both tmYRDataBottomF and tmYRDataTop are
> outside of the range of the values in tmYRCoordPoints, can not continue
>
> fatal:TickMarkSetValues: A fatal error was detected while examining
> NhlIRREGULAR style values,cannot continue
> fatal:PlotManagerSetValues: Error setting TickMark values
> fatal:ContourPlotSetValues: error setting overlay object view
> warning:ContourPlotSetValues: Y coordinates out of data range: defaulting
> warning:ContourPlotSetValues: Zero Y coordinate span:
> defaulting:[errno=1104]
> warning:ContourPlotSetValues: current transformation requires trYMinF to
> be within data coordinate range: resetting
> warning:ContourPlotSetValues: Y coordinates out of data range: defaulting
> warning:ContourPlotSetValues: Zero Y coordinate span:
> defaulting:[errno=1104]
> warning:ContourPlotSetValues: current transformation requires trYMinF to
> be within data coordinate range: resetting
> warning:ContourPlotSetValues: Y coordinates out of data range: defaulting
> warning:ContourPlotSetValues: Zero Y coordinate span:
> defaulting:[errno=1104]
> warning:ContourPlotSetValues: current transformation requires trYMinF to
> be within data coordinate range: resetting
> fatal:TickMark:CheckIrregular: Both tmYRDataBottomF and tmYRDataTop are
> outside of the range of the values in tmYRCoordPoints, can not continue
>
> fatal:TickMarkSetValues: A fatal error was detected while examining
> NhlIRREGULAR style values,cannot continue
> fatal:ContourPlotSetValues: error setting overlay object view
> avondou_at_berbench:/media/Shared/WA_meteosat/tout/all$
> avondou_at_berbench:/media/Shared/WA_meteosat/tout/all$
> avondou_at_berbench:/media/Shared/WA_meteosat/tout/all$
> avondou_at_berbench:/media/Shared/WA_meteosat/tout/all$ ncl contour_shaded.ncl
> Copyright (C) 1995-2007 - All Rights Reserved
> University Corporation for Atmospheric Research
> NCAR Command Language Version 5.0.0
> The use of this software is governed by a License Agreement.
> See http://www.ncl.ucar.edu/ for more details.
> warning:ContourPlotInitialize: Y coordinates out of data range: defaulting
> warning:ContourPlotInitialize: Zero Y coordinate span:
> defaulting:[errno=1104]
> warning:ContourPlotInitialize: current transformation requires trYMinF
> to be within data coordinate range: resetting
> warning:TransInitialize: min Y coordinate exceeds max: exchanging
> warning:IrTransInitialize: trYCoordPoints contains invalid coordinate
> array: defaulting trYAxisType to LinearAxis
> warning:ContourPlotSetValues: Y coordinates out of data range: defaulting
> warning:ContourPlotSetValues: Zero Y coordinate span:
> defaulting:[errno=1104]
> warning:ContourPlotSetValues: current transformation requires trYMinF to
> be within data coordinate range: resetting
> fatal:TickMark:CheckIrregular: Both tmYRDataBottomF and tmYRDataTop are
> outside of the range of the values in tmYRCoordPoints, can not continue
>
> fatal:TickMarkSetValues: A fatal error was detected while examining
> NhlIRREGULAR style values,cannot continue
> fatal:PlotManagerSetValues: Error setting TickMark values
> fatal:ContourPlotSetValues: error setting overlay object view
> warning:ContourPlotSetValues: Y coordinates out of data range: defaulting
> warning:ContourPlotSetValues: Zero Y coordinate span:
> defaulting:[errno=1104]
> warning:ContourPlotSetValues: current transformation requires trYMinF to
> be within data coordinate range: resetting
> warning:ContourPlotSetValues: Y coordinates out of data range: defaulting
> warning:ContourPlotSetValues: Zero Y coordinate span:
> defaulting:[errno=1104]
> warning:ContourPlotSetValues: current transformation requires trYMinF to
> be within data coordinate range: resetting
> warning:ContourPlotSetValues: Y coordinates out of data range: defaulting
> warning:ContourPlotSetValues: Zero Y coordinate span:
> defaulting:[errno=1104]
> warning:ContourPlotSetValues: current transformation requires trYMinF to
> be within data coordinate range: resetting
> fatal:TickMark:CheckIrregular: Both tmYRDataBottomF and tmYRDataTop are
> outside of the range of the values in tmYRCoordPoints, can not continue
>
> fatal:TickMarkSetValues: A fatal error was detected while examining
> NhlIRREGULAR style values,cannot continue
> fatal:ContourPlotSetValues: error setting overlay object view
>
> Here script I am using to create Netcdf data
>
>
> 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"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
>
> begin
>
>
> xtemp = fspan(193, 283, 10)
> ntemp = dimsizes(xtemp)
>
> xtime = fspan(1, 48, 48)
> ntime = dimsizes(xtime)
>
>
> xtemp_at_units = "K"
> xtemp_at_long_name = "Temperature"
> xtime_at_units = "LST"
> xtime_at_long_name = "Time"
>
>
>
> fili = systemfunc("ls XYZ_Area_025_R1")
> nfil = dimsizes( fili )
>
> do n = 0, nfil - 1
> name = stringtocharacter(fili(n))
> ; name1 = name(0:18)
> ; name2 = chartostring(name1)
>
> dummy_data = asciiread(fili(n), (/ntemp, ntime/), "float")
>
> ; Set up coordinate arrays so we can overlay on map.
> dummy_data!0 = "temperature"
> dummy_data!1 = "time"
> dummy_data&temperature = xtemp
> dummy_data&time = xtime
> dummy_data_at_units = "%"
> dummy_data@_FillValue = -9999.
> dummy_data_at_missing_value = dummy_data@_FillValue
> dummy_data_at_long_name = "Fractional coverage"
>
> diro = "./" ; Output directory
> filo = name+".nc" ; Output file
> system("/bin/rm -f " + diro + filo) ; remove if exists
> fout = addfile (diro + filo, "c") ; open output file
>
>
> ;===================================================================
> ; explicitly declare file definition mode. Improve efficiency.
> ;===================================================================
> setfileoption(fout, "DefineMode", True)
>
> ;===================================================================
> ; create global attributes of the file
> ;===================================================================
> fAtt = True ; assign file attributes
> fAtt_at_title = "NCL Efficient Approach to netCDF Creation"
> fAtt_at_source_file = "original-file.nc"
> fAtt_at_Conventions = "None"
> fAtt_at_creation_date = systemfunc ("date")
> fileattdef(fout, fAtt) ; copy file attributes
> ;===================================================================
> ; predefine the coordinate variables and their dimensionality
> ; note: to get an UNLIMITED record dimension, we set the dimensionality
> ; to -1 and set the unlimited array to True.
> ;===================================================================
> dimNames = (/"temperature", "time"/)
> dimSizes = (/ntemp, ntime/)
> dimUnlim = (/False, False/)
> filedimdef(fout, dimNames, dimSizes, dimUnlim)
>
>
>
> filevardef(fout, "temperature", typeof(xtemp),
> "temperature")
> filevardef(fout, "time", typeof(xtime),
> "time")
> filevardef(fout, "FC", typeof(dummy_data), (/"temperature",
> "time"/))
>
>
> filevarattdef(fout, "temperature", xtemp) ; copy lat
> attributes
> filevarattdef(fout, "time", xtime) ; copy
> lon attributes
> filevarattdef(fout, "FC", dummy_data) ; copy TOPOG
> attributes
>
> setfileoption(fout, "DefineMode", False)
>
>
> fout->temeparture = (/xtemp/)
> fout->time = (/xtime/)
> fout->FC = (/dummy_data/)
>
>
> delete(dummy_data)
> delete(fout)
>
>
> end do
>
>
> end
>
>
> This is the script for the plot (derived from
> www.ncl.ucar.edu/Applications/Scripts/conwomap_1.ncl)
>
> ;================================================;
> ; conwomap_1.ncl
> ;================================================;
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> ; ================================================;
> begin
> ;=================================================;
> ; open file and read in data
> ;=================================================;
> f = addfile("XYZ_Area_025_R3.nc","r")
> u = f->FC
> ;=================================================;
> ; PLOT 2
> ;=================================================;
> wks = gsn_open_wks("ps","conwomap") ; open a ps file
> plot = gsn_csm_contour(wks, u, False) ; contour the variable
>
> ; note that the default plot draw here still uses the long_name and
> ; units of the variable as labels.
>
> ; In this file, the coordinate variables of the data are listed as
> ; lat and long, but they are really just index points, which makes this
> ; data suitable for plotting without a map.
> end
>
> And attached file which I am using to create netcdf file
>
>
> Thanks for help
>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> En finir avec le spam? Yahoo! Mail vous offre la meilleure protection
> possible contre les messages non sollicités
> http://mail.yahoo.fr Yahoo! Mail
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
--------------------------------------------------------------
Adam Phillips			             asphilli_at_ucar.edu
National Center for Atmospheric Research   tel: (303) 497-1726
ESSL/CGD/CAS                               fax: (303) 497-1333
P.O. Box 3000				
Boulder, CO 80307-3000	  http://www.cgd.ucar.edu/cas/asphilli
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue May 13 2008 - 10:01:21 MDT

This archive was generated by hypermail 2.2.0 : Mon May 19 2008 - 08:42:48 MDT