Re: problem reading/plotting data

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Sun, 16 Nov 2008 12:44:28 -0700

Hi Susan,

In order to use one of the contouring functions, they either expect a
1D or 2D array, and you are passing a 3D array.

I think you just need to further subscript the "time" dimension of
"mean" so that it collapses it to a 2D array:

    meanai = cdf_file->mean(0,0,:,:)

--Mary

On Nov 16, 2008, at 12:31 PM, Susan Kaspari wrote:

> Hello,
> I am trying to read in a file to plot using gsn_csm_contour_map_ce,
> and am having a problem with defining the dimensions of the file.
> The script is below, and I've put in bold the lines where I am
> having a problem. I also have included below the file attirbutes.
> I want to plot the mean field, but am not sure how to define the
> dimensions of the file (time, level001, latitude, longitude) when i
> read in the data. I know this is basic, but I'm not sure which
> should be 0 as opposed to :, but can't find information on this on
> the website. Help would be very much appreciated!
> Thank you,
> Susan
>
>
> ;************************************************
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> ;************************************************
> begin
> ;************************************************
> ; read in netCDF file
> ;************************************************
> cdf_file = addfile("MeanTOMSAI19801991.nc","r")
> ;************************************************
> ; read in mean data
> ;************************************************
> meanai = cdf_file->mean(:,0,:,:)
> ;************************************************
> ; plotting parameters
> ;************************************************
> wks = gsn_open_wks("ps","TOMSmean")
> res = True
>
> gsn_define_colormap(wks,"ViBlGrWhYeOrRe") ; choose
> colormap
>
> res_at_cnFillOn = True ; turn on color
> res_at_gsnSpreadColors = True ; use full colormap
> res_at_cnLinesOn = False ; turn off contour
> lines
> res_at_lbLabelAutoStride = True ; automatic lb label
> stride
> ;res_at_cnLevelSelectionMode = "ManualLevels" ; manually set cn
> levels
> ;res_at_cnMinLevelValF = 0 ; min level
> ;res_at_cnMaxLevelValF = 30 ; max level
> ;res_at_cnLevelSpacingF = 2 ; contour level spacing
> SCRIPT TAKES MUCH LONGER TO RUN WITH INTERVAL AT .1
>
> ;res_at_mpMinLatF = -60 ; range to zoom in on
> ;res_at_mpMaxLatF = 60.
> ;res_at_mpMinLonF = -180.
> ;res_at_mpMaxLonF = 180.
>
> plot = gsn_csm_contour_map_ce(wks,menai,res)
>
> end
>
> filename: MeanTOMSAI1980-1991
> path: MeanTOMSAI1980-1991.nc
> file global attributes:
> title : ./bin/getmomentsfield TOMSData/toms2.ctl mean month 1
> ave 12 begin 1980 end 1991 restrain 0 ./data/m497.ctl
> Conventions : COARDS
> GFDL_NCIR_VER_NO : 0.7
> missing_value : 3e+33
> dimensions:
> longitude = 288
> latitude = 120
> level001 = 1
> time = 1 // unlimited
> variables:
> float longitude ( longitude )
> long_name : Longitude values
> cartesian_axis : X
> units : degrees_E
> ipositive : 1
>
> float latitude ( latitude )
> long_name : Latitudes values
> cartesian_axis : Y
> units : degrees_N
> ipositive : 1
>
> float level001 ( level001 )
> long_name : Level values
> cartesian_axis : Z
> units : level
> ipositive : 1
> positive : up
>
> double time ( time )
> long_name : Time coordinate values
> cartesian_axis : T
> units : months since 1-01-15 00:00:00.0
> ipositive : 1
> calendar : Gregorian
>
> float mean ( time, level001, latitude, longitude )
> long_name : mean
> units : unknown
> valid_range : <ARRAY>
> missing_value : 3e+33
> _FillValue : 3e+33
>
> float sd ( time, level001, latitude, longitude )
> long_name : standard deviation
> units : unknown
> valid_range : <ARRAY>
> missing_value : 3e+33
> _FillValue : 3e+33
>
> float skew ( time, level001, latitude, longitude )
> long_name : skewness
> units : 1
> valid_range : <ARRAY>
> missing_value : 3e+33
> _FillValue : 3e+33
>
> float kurt ( time, level001, latitude, longitude )
> long_name : kurtosis
> units : 1
> valid_range : <ARRAY>
> missing_value : 3e+33
> _FillValue : 3e+33
>
> float adev ( time, level001, latitude, longitude )
> long_name : absolute deviation
> units : unknown
> valid_range : <ARRAY>
> missing_value : 3e+33
> _FillValue : 3e+33
>
> float sdm ( time, level001, latitude, longitude )
> long_name : standard deviation / mean
> units : 1
> valid_range : <ARRAY>
> missing_value : 3e+33
> _FillValue : 3e+33
>
> float min ( time, level001, latitude, longitude )
> long_name : minimum
> units : unknown
> valid_range : <ARRAY>
> missing_value : 3e+33
> _FillValue : 3e+33
>
> float max ( time, level001, latitude, longitude )
> long_name : maximum
> units : unknown
> valid_range : <ARRAY>
> missing_value : 3e+33
> _FillValue : 3e+33
>
> _______________________________________________
> 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
Received on Sun Nov 16 2008 - 12:44:28 MST

This archive was generated by hypermail 2.2.0 : Wed Nov 19 2008 - 10:42:49 MST