Re: change varable

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed Oct 26 2011 - 09:09:32 MDT

Hussain,

You didn't state how want to change the variable.

In your original script, the PRCP variable was being read in with:

   rain_tot = a->PRCP(it,:,:)

and then the UnitLabel and description attributes were being updated
with:

   rain_tot@description = "Total Monthly Precipitation"
   rain_tot@UnitLabel = "mm"

In your case, to read in PMSL, I would do this:

   pmsl = a->PMSL(it,:,:)

Or, if you want to read in the whole variable:

   pmsl = a->PMSL

You can then examine "pmsl" by using printVarSummary:

printVarSummary(pmsl)

This prints out the dimensions and type of your variable, along with
any attributes and dimension names. It would also print the name of
any coordinate arrays, but it looks like you don't have those in this
file.

Note that once you read in the variable, NCL automatically reads in
all the attributes and dimension names for you as part of the same
variable.
You don't need to read these in separately.

You didn't say how you wanted to change the variable, but let's say
you want to change the units from "hPa" to "Pa". You would
do something like this:

   pmsl = pmsl*100
   pmsl@units = "Pa"

Now when you do a "printVarSummary(pmsl)" it will look the same,
except the "units" attribute will be changed.

To actually print the values of pmsl, you can use "print", or
"write_matrix" (for a 2D array)

   print(pmsl) ; This prints one value per line, can be a lot
of output

You can print just the min and max of your data:

   print ("min/max pmsl = " + min(pmsl) + "/" + max(pmsl))

You can look at example "WRF_cn_2.ncl" at:

http://www.ncl.ucar.edu/Applications/wrfcn.shtml

The script reads in three variables and changes them slightly
to either change the units or add more attributes.

The plotting is done with an old script, so you should probably
ignore this for now. For plotting WRF data, you should look
at the WRF Online tutorial:

http://www.mmm.ucar.edu/wrf/OnLineTutorial/Graphics/NCL/NCL_examples.htm

Good luck,

--Mary

On Oct 25, 2011, at 8:58 PM, Hussain Alsarraf wrote:

> Hi
>
> Im looking to change the variable in my scripts. The variable in my
> header dump that i would like to shange too is:
>
> float PMSL(time, south_north, west_east) ;
> PMSL:coordinates = "XLONG XLAT" ;
> PMSL:stagger = ;
> PMSL:units = "hPa" ;
> PMSL:description = "pressure at mean sea level" ;
> PMSL:MemoryOrder = "XY " ;
> PMSL:FieldType = 104 ;
> PMSL:_FillValue = -999.f ;
>
>
> The original scripts :
>
> ; First get the variable
>
> rain_tot = a->PRCP(it,:,:)
>
> ; Plotting options for Variable
> ; change to correspond with Variable
> rain_tot@description = "Total Monthly Precipitation"
> res@UnitLabel = "mm"
>
> should i change the scripts to :
> ; First get the variable
>
> rain_tot = a->PRCP(it,:,:)
>
> ; Plotting options for Variable
> ; change to correspond with Variable
> PMSL:description = "pressure at mean sea level" ;
> PMSL:units = "hPa" ;
>
> please let me know if i need to change something els
>
> thanks
>
>
>
> _______________________________________________
> 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 Wed Oct 26 09:09:39 2011

This archive was generated by hypermail 2.1.8 : Fri Oct 28 2011 - 10:52:03 MDT