[ncl-talk] zonal_mpsi

Ipshita Majhi ipmajhi at alaska.edu
Sat Sep 10 22:05:19 MDT 2016


Thank you Dennis and Adam, finally the code is running. I am grateful for
your inputs

Best Regards
Ipshita

On Sat, Sep 10, 2016 at 6:09 AM, Dennis Shea <shea at ucar.edu> wrote:

> diri = "/Users/ipshita/Documents/grads_NCL/"
>
> c=addfile(diri+"vwnd.2008.nc","r")
> e=addfile(diri+"pres.sfc.mon.mean.nc","r")
>
> v  = c->vwnd                    ; (time,level,lat,lon)
> ps = e->pres                    ; (time,lat,lon)        hPa
>
> printVarSummary(ps)
> print("---")
> printVarSummary(v)
> print("---")
> print(v&level)                  ; hPa  (1000-10) => bottom-to-top
> print("---")
> ; =========================
> ; function requires top-to-bottom; reverse order
> ;==========================
> v = v(:,::-1,:,:)
>
> printVarSummary(v)
> print("---")
> print(v&level)                  ; hPa  (10-1000) => top-to-bottom
> print("---")
>
> ; =========================
> ; function requires Pa ... not hPa/mb
> ;==========================
> ps =(/ ps*100 /)                     ; function requires Pa
> ps at units = "Pa"
>
> v&level = (/ 100*v&level /)     ; function requires Pa
> v&level at units = "Pa"
>
> zmpsi = zonal_mpsi_Wrap(v, v&lat, v&level, ps)
> printVarSummary(zmpsi)
>
>
> On Fri, Sep 9, 2016 at 5:10 PM, Adam Phillips <asphilli at ucar.edu> wrote:
>
>> Hi Ipshita,
>> The printVarSummary output shows what the problem is:
>> Type: float
>> Total Size: 714816 bytes
>>             178704 values
>> Number of Dimensions: 3
>> Dimensions and sizes: [level | 17] x [lat | 73] x [lon | 144]
>> Coordinates:
>>             level: [10..1000]
>>
>> The error message that you are recieving states that the levels need to
>> be in Pa:
>> fatal:zonal_mpsi: The pressure array must be between the values of 500
>> and 100500 (exclusive), and monotonically increasing.
>>
>> Thus, you need to convert your pressure levels to Pa. I am unsure whether
>> zonal_mpsi uses the level coordinate variable attached to your v1 array, so
>> it is probably better to change that (as opposed to just altering the
>> v1&level array itself.
>>
>> level = v1&level
>> delete(v1&level)
>> level = level*100.
>> level&level = level
>> level at units = "Pa"
>> v1&level = level
>>
>> That should fix the issue..
>> Adam
>>
>>
>>
>> On Fri, Sep 9, 2016 at 12:01 PM, Ipshita Majhi <ipmajhi at alaska.edu>
>> wrote:
>>
>>> Hi ,
>>>
>>> Thank you for your input. I did try the above mentioned correction. I
>>> still get an error :
>>>
>>> fatal:zonal_mpsi: The pressure array must be between the values of 500
>>> and 100500 (exclusive), and monotonically increasing
>>>
>>> Here is the printVarSummary and print for v1 Variable: v1
>>>
>>> Type: float
>>> Total Size: 714816 bytes
>>>             178704 values
>>> Number of Dimensions: 3
>>> Dimensions and sizes: [level | 17] x [lat | 73] x [lon | 144]
>>> Coordinates:
>>>             level: [10..1000]
>>>             lat: [90..-90]
>>>             lon: [ 0..357.5]
>>> Number Of Attributes: 14
>>>   long_name : Monthly mean v wind
>>>   units : m/s
>>>   precision : 2
>>>   least_significant_digit : 1
>>>   var_desc : v-wind
>>>   level_desc : Multiple levels
>>>   statistic : Mean
>>>   parent_stat : Other
>>>   missing_value : -9.96921e+36
>>>   valid_range : ( -125, 160 )
>>>   dataset : NCEP Reanalysis Derived Products
>>>   actual_range : ( -68.57001, 68.56999 )
>>>   _FillValue : -9.96921e+36
>>>   time : 1297320
>>>
>>>
>>> Variable: level (coordinate)
>>> Type: float
>>> Total Size: 68 bytes
>>>             17 values
>>> Number of Dimensions: 1
>>> Dimensions and sizes: [level | 17]
>>> Coordinates:
>>> Number Of Attributes: 7
>>>   units : millibar
>>>   long_name : Level
>>>   positive : down
>>>   GRIB_id : 100
>>>   GRIB_name : hPa
>>>   actual_range : ( 1000, 10 )
>>>   axis : Z
>>> (0) 10
>>> (1) 20
>>> (2) 30
>>> (3) 50
>>> (4) 70
>>> (5) 100
>>> (6) 150
>>> (7) 200
>>> (8) 250
>>> (9) 300
>>> (10) 400
>>> (11) 500
>>> (12) 600
>>> (13) 700
>>> (14) 850
>>> (15) 925
>>> (16) 1000
>>>
>>> Variable: PsPa
>>> Type: float
>>> Total Size: 42048 bytes
>>>             10512 values
>>> Number of Dimensions: 2
>>> Dimensions and sizes: [73] x [144]
>>> Coordinates:
>>> Number Of Attributes: 1
>>>   _FillValue : -9.96921e+36
>>>
>>>
>>>
>>>
>>> On Fri, Sep 9, 2016 at 8:10 AM, Adam Phillips <asphilli at ucar.edu> wrote:
>>>
>>>> Hi Ipshita,
>>>> You are altering the order of your level dimension here:
>>>> v1=v_jan_1948(::-1,:,:)
>>>> and that is completely fine. However, you are then flipping the level
>>>> dimension again here when you specify v1&level:
>>>> zmpsi = zonal_mpsi(v1,v1&lat,v1&level(::-1),PsPa)
>>>>
>>>> Try changing this:
>>>> zmpsi = zonal_mpsi(v1,v1&lat,v1&level(::-1),PsPa)
>>>> to this:
>>>> zmpsi = zonal_mpsi(v1,v1&lat,v1&level,PsPa)
>>>>
>>>> If that does not fix the issue please add printVarSummary and print
>>>> statements to your script and examine the output. The end of your script
>>>> should look like this:
>>>> v1=v_jan_1948(::-1,:,:)
>>>> PsPa=ps_jan_1948*100
>>>> printVarSummary(v1)
>>>> print(v1&level)
>>>> zmpsi = zonal_mpsi(v1,v1&lat,v1&level,PsPa)
>>>>
>>>> If you still are having trouble please respond to the ncl-talk email
>>>> list with the printVarSummary and print output.
>>>> Adam
>>>>
>>>>
>>>> On Thu, Sep 8, 2016 at 5:02 PM, Ipshita Majhi <ipmajhi at alaska.edu>
>>>> wrote:
>>>>
>>>>>
>>>>> Dear Users,
>>>>>
>>>>> I want to plot stream function of wind (v) and I am using zonal_mpsi
>>>>> to calculate the stream function. I keep getting error messages.
>>>>>
>>>>> fatal:zonal_mpsi: The pressure array must be between the values of 500
>>>>> and 100500 (exclusive), and monotonically increasing.
>>>>>
>>>>> I am not sure how to fix this problem.
>>>>>
>>>>> I am attaching my code.
>>>>>
>>>>> I read in the V wind and surface pressure
>>>>>
>>>>> v-wind has 4 dimensions (time,lev,lat,lon)
>>>>>
>>>>> Surface pressure has 3 dimensions (time,lat,lon)
>>>>>
>>>>> Here is the code I wrote
>>>>>
>>>>> ;**************************************************************
>>>>> ;*******************************************
>>>>> 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"
>>>>> ;*******************************************
>>>>>
>>>>> ;********************************************
>>>>> ;This is to read wind speed and wind direction
>>>>> ;from 1948-2016
>>>>> ;********************************************
>>>>>
>>>>> a=addfile("/Users/ipshita/Documents/grads_NCL/wspd.mon.mean.nc","r")
>>>>> b=addfile("/Users/ipshita/Documents/grads_NCL/uwnd.mon.mean.nc","r")
>>>>> c=addfile("/Users/ipshita/Documents/grads_NCL/vwnd.mon.mean.nc","r")
>>>>> d=addfile("/Users/ipshita/Documents/grads_NCL/omega.mon.mean.nc","r")
>>>>> e=addfile("/Users/ipshita/Documents/grads_NCL/pres.sfc.mon.mean.nc
>>>>> ","r")
>>>>>
>>>>> v=c->vwnd   ;Wind in horizontal direction in m/s
>>>>>
>>>>> level=c->level ;Pressure level from 1000hpa to 10 hpa
>>>>>
>>>>> lat=c->lat
>>>>>
>>>>> lon=c->lon
>>>>>
>>>>> ps=e->pres
>>>>>
>>>>> ps_jan_1948=ps(0,:,:)
>>>>>
>>>>> printMinMax(ps_1948_2015,False)
>>>>>
>>>>> v_jan_1948=v(0,:,:,:)
>>>>> ;*********************************************
>>>>> ;Going from low to high in terms of level
>>>>> ;*********************************************
>>>>>
>>>>> v1=v_jan_1948(::-1,:,:)
>>>>> ;*********************************************
>>>>> ;Converting Pressure into Pascals
>>>>> ;*********************************************
>>>>>
>>>>> PsPa=ps_jan_1948*100
>>>>>
>>>>> printMinMax(PsPa,False)
>>>>>
>>>>> ;*********************************************
>>>>> zmpsi = zonal_mpsi(v1,v1&lat,v1&level(::-1),PsPa)
>>>>> ;*******************************************************************
>>>>>
>>>>> I will be grateful if you can help me resolve this issue.
>>>>>
>>>>> Best Regards
>>>>> Ipshita
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> ncl-talk mailing list
>>>>> ncl-talk at ucar.edu
>>>>> List instructions, subscriber options, unsubscribe:
>>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Adam Phillips
>>>> Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
>>>> www.cgd.ucar.edu/staff/asphilli/   303-497-1726
>>>>
>>>> <http://www.cgd.ucar.edu/staff/asphilli>
>>>>
>>>
>>>
>>>
>>> --
>>> Ipshita Majhi
>>> PhD Candidate
>>> University of Alaska , Fairbanks
>>> Atmospheric Science Department
>>> (907)978-4220 ipmajhi at alaska.edu
>>>
>>
>>
>>
>> --
>> Adam Phillips
>> Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
>> www.cgd.ucar.edu/staff/asphilli/   303-497-1726
>>
>> <http://www.cgd.ucar.edu/staff/asphilli>
>>
>> _______________________________________________
>> 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/20160910/dc24383f/attachment.html 


More information about the ncl-talk mailing list