Re: NCL Help

From: A.R Ragi <ar.ragi_at_nyahnyahspammersnyahnyah>
Date: Thu, 8 Oct 2009 11:21:07 +0530

*Dear Ncl users,**
*
*The error i found is not coming now, by some changes i made. Mainly i used
latGlobeF& lonGlobeF function only.*
*
*
*The new script is like 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"

begin
;
; Read a netCDF file using addfile.
;

a = addfile("TROUT.01-02-00.nc","r")

wks=gsn_open_wks("ps","BCconcentration")

;
;Add Coordinate variables
;

nlat = 221
lat = latGlobeF(nlat, "lat", "latitude", "degrees_north")

mlon = 331
lon = lonGlobeF(mlon, "lon", "longitude", "degrees_east")

bcc1 = a->BC1(0,0,:,:)
bcc2 = a->BC2(0,0,:,:)

TotBC = bcc1+bcc2

TotBC!0 = "lat"
TotBC!1 = "lon"

TotBC&lon = lon
TotBC&lat = lat

printVarSummary(TotBC)
print(TotBC&lat)
print(TotBC&lon)

gsn_define_colormap(wks,"gui_default") ; select color map

  res = True ; plot mods desired
  res_at_gsnSpreadColors = True ; make cn span entire color
map

  res_at_mpFillOn = False ; turn off gray continents
  res_at_cnFillOn = True ; turn on color fill
  res_at_mpMinLonF = 48 ; set min lon
  res_at_mpMaxLonF = 100 ; set max lon
  res_at_mpMinLatF = 0 ; set min lat
  res_at_mpMaxLatF = 30 ; set max lat

  plot = gsn_csm_contour_map_ce(wks,TotBC,res) ; create plot

end

*But the problem is still there with fspan.....!!!!!*
*
*
*Cant we use fspan for setting lat and lon?*
*
*
*
*
*The regional setting made was:(which still shows error)*

;nlat = 221
;mlon = 331

;lat = fspan(0,30,nlat)
;lon = fspan(48,100,mlon)

;lat!0 = "lat"
;lat&lat = lat
;lat_at_units = "degress_north"
;lat_at_long_name = "latitude"

;lon!0 = "lon"
;lon&lon = lon
;lon_at_units = "degress_east"
;lon_at_long_name = "longitude"

*Thanks.....!!!!*

--
A.R.Ragi or simply A.R
MTech Atmospheric Science
CUSAT/CDAC
+919960462099
Sent from Maharashtra, India
On Thu, Oct 8, 2009 at 10:35, A.R Ragi <ar.ragi_at_gmail.com> wrote:
> *Dear Saji , David and all,**
> *
> *I printed TotBC and TotBC&lat and TotBC&lon.*
> *The TotBC output is like:*
>
> Variable: TotBC
> Type: float
> Total Size: 292604 bytes
>             73151 values
> Number of Dimensions: 2
> Dimensions and sizes:   [lat | 221] x [lon | 331]
> Coordinates:
>             lat: [-59.875..20]
>             lon: [60..120]
> (0)     check_for_y_lat_coord: Warning: Data either does not contain a
> valid latitude coordinate array or doesn't contain one at all.
> (0)     A valid latitude coordinate array should have a 'units' attribute
> equal to one of the following values:
> (0)         'degrees_north' 'degrees-north' 'degree_north' 'degrees north'
> 'degrees_N' 'Degrees_north' 'degree_N' 'degreeN' 'degreesN' 'deg north'
> (0)     check_for_lon_coord: Warning: Data either does not contain a valid
> longitude coordinate array or doesn't contain one at all.
> (0)     A valid longitude coordinate array should have a 'units' attribute
> equal to one of the following values:
> (0)         'degrees_east' 'degrees-east' 'degree_east' 'degrees east'
> 'degrees_E' 'Degrees_east' 'degree_E' 'degreeE' 'degreesE' 'deg east'
>
>
>
> The TotBC&lat and TotBC&lon is also printing.
> *
> *
> *But the error is still remaining.*
> *
> *
> *Thanks for help.*
> --
> A.R.Ragi or simply A.R
> MTech Atmospheric Science
> CUSAT/CDAC
> +919960462099
>
>
> Sent from Maharashtra, India
>
> ---------- Forwarded message ----------
> From: A.R Ragi <ar.ragi_at_gmail.com>
> Date: Thu, Oct 8, 2009 at 10:22
> Subject: NCL Help
> To: dbrown_at_ucar.edu
>
>
>
> --
> A.R.Ragi or simply A.R
> MTech Atmospheric Science
> CUSAT/CDAC
> +919960462099
>
>
> Sent from Maharashtra, India
>
> ---------- Forwarded message ----------
> From: A.R Ragi <ar.ragi_at_gmail.com>
> Date: Thu, Oct 8, 2009 at 10:19
> Subject: NCL Help
> To: ncl-talk_at_ucar.edu
>
>
>
> Sent from Maharashtra, India
>
> ---------- Forwarded message ----------
> From: A.R Ragi <ar.ragi_at_gmail.com>
> Date: Thu, Oct 8, 2009 at 10:17
> Subject: Re: NCL Help
> To: Saji <saji_at_apcc21.net>
>
>
> *Dear Ncl Users,*
> *
> *
> *I tried by adding the steps you recommended . The errors showing now are:
> *
>
>
>
> Variable: bcc1
> Type: float
> Total Size: 292604 bytes
>             73151 values
> Number of Dimensions: 2
> Dimensions and sizes:   [ROW | 221] x [COL | 331]
> Coordinates:
> Number Of Attributes: 3
>   long_name :   BC1
>   units :       microgram/m3
>   var_desc :    Species Concentration
> fatal:No coordinate variable exists for dimension (ROW) in variable (bcc1)
> fatal:Execute: Error occurred at or near line 53 in file bcoc.ncl
>
>
>
>
> *Again I changed the following steps and tried:*
>
> ;print(bcc1&ROW)
> ;print(bcc1&COL)
>
>
> *So i got the same errors that lat and lon is not there.*
>
>
> Variable: bcc1
> Type: float
> Total Size: 292604 bytes
>             73151 values
> Number of Dimensions: 2
> Dimensions and sizes:   [ROW | 221] x [COL | 331]
> Coordinates:
> Number Of Attributes: 3
>   long_name :   BC1
>   units :       microgram/m3
>   var_desc :    Species Concentration
> (0)     check_for_y_lat_coord: Warning: Data either does not contain a
> valid latitude coordinate array or doesn't contain one at all.
> (0)     A valid latitude coordinate array should have a 'units' attribute
> equal to one of the following values:
> (0)         'degrees_north' 'degrees-north' 'degree_north' 'degrees north'
> 'degrees_N' 'Degrees_north' 'degree_N' 'degreeN' 'degreesN' 'deg north'
> (0)     check_for_lon_coord: Warning: Data either does not contain a valid
> longitude coordinate array or doesn't contain one at all.
> (0)     A valid longitude coordinate array should have a 'units' attribute
> equal to one of the following values:
> (0)         'degrees_east' 'degrees-east' 'degree_east' 'degrees east'
> 'degrees_E' 'Degrees_east' 'degree_E' 'degreeE' 'degreesE' 'deg east'
>
>
>
> *Is it needed to add lat and lon values in both bcc1 and bcc2 then can
> find TotBC?*
> *
> *
> *Or anything else?*
> *
> *
> *
> *
> *Thanks in advance....!!!!!*
>
> --
> A.R.Ragi or simply A.R
> MTech Atmospheric Science
> CUSAT/CDAC
> +919960462099
>
>
> Sent from Maharashtra, India
>
> On Wed, Oct 7, 2009 at 17:57, Saji <saji_at_apcc21.net> wrote:
>
>> Ragi,
>>
>> > mlon = 150
>> > lon  = lonGlobeF(mlon, "lon", "longitude", "degrees_east")
>> > nlat = 100
>> > lat  = latGlobeF(nlat, "lat", "latitude", "degrees_north")
>> > TotBC!0 = "lat"
>> > TotBC!1 = "lon"
>>
>> First of all, you need to also do the following
>>
>> TotBC&lon = lon
>> TotBC&lat = lat
>>
>> Secondly, I see a mismatch between your description of the size of
>> lat and lon co-ordinates from the output from ncl_filedump. According to
>> ncl_filedump:
>> >    dimensions:
>> >       TSTEP = 4  // unlimited
>> >       DATE-TIME = 2
>> >       LAY = 41
>> >       VAR = 31
>> >       ROW = 221
>> >       COL = 331
>>
>>  lat should have a size of 221 and lon of 331. In contrast you use
>> 100 and 150 resp. Maybe you should print out the following and check
>> if it looks like a latitude/longitude description.
>>
>> printVarSummary(bcc1)
>> print(bcc1&ROW)
>> print(bcc1&COL)
>>
>> You may get a clue on how to define your latitude/longitude co-ordinate
>> values based on this information...
>>
>>
>> saji
>>
>>
>>
>>
>> * A.R Ragi <ar.ragi_at_gmail.com> [2009-10-07 17:00:20 +0530]:
>>
>> > Dear NCL users,
>> >
>> >
>> > I was trying to write the black carbon and organic carbon concentration
>> > script from the STEM model output.
>> >
>> > The output contains BC1, BC2,OC1, OC2.
>> >
>> > But it doesn't contains the Latitude and longitude. Last time asked
>> about
>> > the doubt  in ncl talk and so from the reply I tried to add lat and lon
>> > using both fspan and latGlobeF and lonGlobeF.
>> >
>> > But still saying error remains.
>> >
>> > I'm sure that the error remains with my code itself.
>> >
>> > Can you please check the code and help me.
>> >
>> > The file description and my code is following.
>> >
>> >
>> >
>> > The description of the file is:
>> >
>> >
>> > Variable: f (file variable)
>> >
>> > filename:       TROUT.01-02-00
>> > path:   TROUT.01-02-00.nc
>> >    file global attributes:
>> >       IOAPI_VERSION : $Id: @(#) ioapi library version 3.0 $
>> >       EXEC_ID : 3.0
>> >       FTYPE : 1
>> >       CDATE : 2009252
>> >       CTIME : 61455
>> >       WDATE : 2009252
>> >       WTIME : 61455
>> >       SDATE : 2006002
>> >       STIME : 0
>> >       TSTEP : 60000
>> >       NTHIK : 1
>> >       NCOLS : 331
>> >       NROWS : 221
>> >       NLAYS : 41
>> >       NVARS : 31
>> >       GDTYP : 3
>> >       P_ALP : 17.5
>> >       P_BET : 17.5
>> >       P_GAM :    0
>> >       XCENT :   75
>> >       YCENT : 17.49999618530273
>> >       XORIG : 28.14615058898926
>> >       YORIG : -20.71478080749512
>> >       XCELL : 27000
>> >       YCELL : 27000
>> >       VGTYP : 2
>> >       VGTOP :  1
>> >       VGLVLS : <ARRAY of 42 elements>
>> >       GDNAM : WRF
>> >       UPNAM :
>> >       VAR-LIST : SO2             VSO2            SO2LPS          NOX
>> >     NOY             HC1             HC2             HC3
>> BIOMCO
>> >        Hg              CO              CO_TRACER1      CO_TRACER2
>> >  CO_TRACER3      CO_TRACER4      CO_TRACER5      CO_TRACER6
>>  CO_TRACER7
>> >      CO_TRACER8      CO_TRACER9      CO_TRACER10     CO_TRACER11
>> SULF
>> >          BC1             BC2             OC1             OC2
>> SSF
>> >             SSC             DUST1           DUST2
>> >       FILEDESC : Generated by program AQMS
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >       HISTORY :
>> >    dimensions:
>> >       TSTEP = 4  // unlimited
>> >       DATE-TIME = 2
>> >       LAY = 41
>> >       VAR = 31
>> >       ROW = 221
>> >       COL = 331
>> >    variables:
>> >       integer TFLAG ( TSTEP, VAR, DATE-TIME )
>> >          units :        <YYYYDDD,HHMMSS>
>> >          long_name :    TFLAG
>> >          var_desc :     Timestep-valid flags:  (1) YYYYDDD or (2) HHMMSS
>> >
>> >       float SO2 ( TSTEP, LAY, ROW, COL )
>> >          long_name :    SO2
>> >          units :        ppbv
>> >          var_desc :     Species Concentration
>> >
>> >       float VSO2 ( TSTEP, LAY, ROW, COL )
>> >          long_name :    VSO2
>> >          units :        ppbv
>> >          var_desc :     Species Concentration
>> >
>> >       float SO2LPS ( TSTEP, LAY, ROW, COL )
>> >          long_name :    SO2LPS
>> >          units :        ppbv
>> >          var_desc :     Species Concentration
>> >
>> >       float NOX ( TSTEP, LAY, ROW, COL )
>> >          long_name :    NOX
>> >          units :        ppbv
>> >          var_desc :     Species Concentration
>> >
>> >       float NOY ( TSTEP, LAY, ROW, COL )
>> >          long_name :    NOY
>> >          units :        ppbv
>> >          var_desc :     Species Concentration
>> >
>> >       float HC1 ( TSTEP, LAY, ROW, COL )
>> >          long_name :    HC1
>> >          units :        ppbv
>> >          var_desc :     Species Concentration
>> >
>> >       float HC2 ( TSTEP, LAY, ROW, COL )
>> >          long_name :    HC2
>> >          units :        ppbv
>> >          var_desc :     Species Concentration
>> >
>> >       float HC3 ( TSTEP, LAY, ROW, COL )
>> >          long_name :    HC3
>> >          units :        ppbv
>> >          var_desc :     Species Concentration
>> >
>> >       float BIOMCO ( TSTEP, LAY, ROW, COL )
>> >          long_name :    BIOMCO
>> >          units :        ppbv
>> >          var_desc :     Species Concentration
>> >
>> >       float Hg ( TSTEP, LAY, ROW, COL )
>> >          long_name :    Hg
>> >          units :        ppbv
>> >          var_desc :     Species Concentration
>> >
>> >       float CO ( TSTEP, LAY, ROW, COL )
>> >          long_name :    CO
>> >          units :        ppbv
>> >          var_desc :     Species Concentration
>> >
>> >       float CO_TRACER1 ( TSTEP, LAY, ROW, COL )
>> >          long_name :    CO_TRACER1
>> >          units :        ppbv
>> >          var_desc :     Species Concentration
>> >
>> >       float CO_TRACER2 ( TSTEP, LAY, ROW, COL )
>> >          long_name :    CO_TRACER2
>> >          units :        ppbv
>> >          var_desc :     Species Concentration
>> >
>> >       float CO_TRACER3 ( TSTEP, LAY, ROW, COL )
>> >          long_name :    CO_TRACER3
>> >          units :        ppbv
>> >          var_desc :     Species Concentration
>> >
>> >       float CO_TRACER4 ( TSTEP, LAY, ROW, COL )
>> >          long_name :    CO_TRACER4
>> >          units :        ppbv
>> >          var_desc :     Species Concentration
>> >
>> >       float CO_TRACER5 ( TSTEP, LAY, ROW, COL )
>> >          long_name :    CO_TRACER5
>> >          units :        ppbv
>> >          var_desc :     Species Concentration
>> >
>> >       float CO_TRACER6 ( TSTEP, LAY, ROW, COL )
>> >          long_name :    CO_TRACER6
>> >          units :        ppbv
>> >          var_desc :     Species Concentration
>> >
>> >       float CO_TRACER7 ( TSTEP, LAY, ROW, COL )
>> >          long_name :    CO_TRACER7
>> >          units :        ppbv
>> >          var_desc :     Species Concentration
>> >
>> >       float CO_TRACER8 ( TSTEP, LAY, ROW, COL )
>> >          long_name :    CO_TRACER8
>> >          units :        ppbv
>> >          var_desc :     Species Concentration
>> >
>> >       float CO_TRACER9 ( TSTEP, LAY, ROW, COL )
>> >          long_name :    CO_TRACER9
>> >          units :        ppbv
>> >          var_desc :     Species Concentration
>> >
>> >       float CO_TRACER10 ( TSTEP, LAY, ROW, COL )
>> >          long_name :    CO_TRACER10
>> >          units :        ppbv
>> >          var_desc :     Species Concentration
>> >
>> >       float CO_TRACER11 ( TSTEP, LAY, ROW, COL )
>> >          long_name :    CO_TRACER11
>> >          units :        ppbv
>> >          var_desc :     Species Concentration
>> >
>> >       float SULF ( TSTEP, LAY, ROW, COL )
>> >          long_name :    SULF
>> >          units :        microgram/m3
>> >          var_desc :     Species Concentration
>> >
>> >       float BC1 ( TSTEP, LAY, ROW, COL )
>> >          long_name :    BC1
>> >          units :        microgram/m3
>> >          var_desc :     Species Concentration
>> >
>> >       float BC2 ( TSTEP, LAY, ROW, COL )
>> >          long_name :    BC2
>> >          units :        microgram/m3
>> >          var_desc :     Species Concentration
>> >
>> >       float OC1 ( TSTEP, LAY, ROW, COL )
>> >          long_name :    OC1
>> >          units :        microgram/m3
>> >          var_desc :     Species Concentration
>> >
>> >       float OC2 ( TSTEP, LAY, ROW, COL )
>> >          long_name :    OC2
>> >          units :        microgram/m3
>> >          var_desc :     Species Concentration
>> >
>> >       float SSF ( TSTEP, LAY, ROW, COL )
>> >          long_name :    SSF
>> >          units :        microgram/m3
>> >          var_desc :     Species Concentration
>> >
>> >       float SSC ( TSTEP, LAY, ROW, COL )
>> >          long_name :    SSC
>> >          units :        microgram/m3
>> >          var_desc :     Species Concentration
>> >
>> >       float DUST1 ( TSTEP, LAY, ROW, COL )
>> >          long_name :    DUST1
>> >          units :        microgram/m3
>> >          var_desc :     Species Concentration
>> >
>> >       float DUST2 ( TSTEP, LAY, ROW, COL )
>> >          long_name :    DUST2
>> >          units :        microgram/m3
>> >          var_desc :     Species Concentration
>> >
>> >
>> >
>> > >
>> > > The code i attempted is:
>> > >
>> > >
>> > >
>> > >
>> > > ;Add Coordinate variables
>> > >
>> > >
>> > >
>> > > 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"
>> > >
>> > >
>> > >
>> > > begin
>> > >
>> > > ;
>> > >
>> > > ;  Read a netCDF file using addfile.
>> > >
>> > > ;
>> > >
>> > >
>> > >
>> > > a = addfile("TROUT.01-02-00.nc","r")
>> > >
>> > >
>> > >
>> > > wks=gsn_open_wks("ps","BCconcentration")
>> > >
>> > >
>> > >
>> > > ;
>> > >
>> > > ;Add Coordinate variables
>> > >
>> > > ;
>> > >
>> > >
>> > >
>> > > ;nlat = 100
>> > >
>> > > ;mlon = 150
>> > >
>> > >
>> > >
>> > > ;lat = fspan(-59.875,20,nlat)
>> > >
>> > > ;lon = fspan(60,120,mlon)
>> > >
>> > >
>> > >
>> > > ;lat!0 = "lat"
>> > >
>> > > ;lat&lat = lat
>> > >
>> > > ;lat_at_units = "degress_north"
>> > >
>> > > ;lat_at_long_name = "latitude"
>> > >
>> > >
>> > >
>> > > ;lon!0 = "lon"
>> > >
>> > > ;lon&lon = lon
>> > >
>> > > ;lon_at_units = "degress_east"
>> > >
>> > > ;lon_at_long_name = "longitude"
>> > >
>> > >
>> > >
>> > >         mlon = 150
>> > >
>> > >         lon  = lonGlobeF(mlon, "lon", "longitude", "degrees_east")
>> > >
>> > >
>> > >
>> > >         nlat = 100
>> > >
>> > >         lat  = latGlobeF(nlat, "lat", "latitude", "degrees_north")
>> > >
>> > >
>> > >
>> > >
>> > >
>> > > bcc1 = a->BC1(0,0,:,:)
>> > >
>> > > bcc2 = a->BC2(0,0,:,:)
>> > >
>> > >
>> > >
>> > > TotBC = bcc1+bcc2
>> > >
>> > >
>> > >
>> > > TotBC!0 = "lat"
>> > >
>> > > TotBC!1 = "lon"
>> > >
>> > >
>> > >
>> > > gsn_define_colormap(wks,"gui_default")
>> > >
>> > >
>> > >
>> > >   res = False
>> > >
>> > >   res_at_gsnSpreadColors      = True
>> > >
>> > >
>> > >
>> > >   res_at_mpFillOn             = False
>> > >
>> > >   res_at_cnFillOn             = True
>> > >
>> > >   res_at_mpMinLonF            = -140
>> > >
>> > >   res_at_mpMaxLonF            =  -65
>> > >
>> > >   res_at_mpMinLatF            =  10.
>> > >
>> > >
>> > >
>> > >   plot = gsn_csm_contour_map_ce(wks,TotBC,res)   ; create plot
>> > >
>> > >
>> > >
>> > >
>> > >
>> > > end
>> > >
>> > > ---
>> > > I'm waiting for your valuable reply. Please reply when you get time.
>> > > Thanks in advance.
>> > >
>> > >
>> > >
>> > > --
>> > > A.R.Ragi or simply A.R
>> > > MTech Atmospheric Science
>> > > CUSAT/CDAC
>> > > +919960462099
>> > >
>> > >
>> > > Sent from Maharashtra, India
>> > >
>>
>> > _______________________________________________
>> > ncl-talk mailing list
>> > List instructions, subscriber options, unsubscribe:
>> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>> --
>> Saji N. Hameed
>>
>> APEC Climate Center
>> 1463 U-dong, Haeundae-gu,                               +82 51 745 3951
>> BUSAN 612-020, KOREA                                    saji_at_apcc21.net
>> Fax: +82-51-745-3999
>>
>>
>>
>>
>
>
>
>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Oct 07 2009 - 23:51:07 MDT

This archive was generated by hypermail 2.2.0 : Fri Oct 09 2009 - 08:29:22 MDT