[ncl-talk] Fw: Re: Fw: area average

Ehsan Taghizadeh ehsantaghizadeh at yahoo.com
Fri Aug 17 14:27:58 MDT 2018


 Dears,Pardon me to forward my questions twice. May I ask how using attached script for multiple files?
SincerelyEhsan
   ----- Forwarded Message ----- From: Ehsan Taghizadeh <ehsantaghizadeh at yahoo.com>To: Ncl-talk <ncl-talk at ucar.edu>; alesall at iri.columbia.edu <alesall at iri.columbia.edu>Sent: Tuesday, August 14, 2018, 7:03:20 PM GMT+4:30Subject: Re: [ncl-talk] Fw: area average
 Thank you for your helps.Dear AlessandraThank you for you comments. A reference of my data could be this page (https://nsidc.org/data/SPL2SMP_E/versions/2). However Dennis's comments about my data are true. I've attached a picture of these data for date 1 April 2018.Also the result of PrintVarSummary(Var):
    Variable: var    Type: float    Total Size: 1124096 bytes                281024 values    Number of Dimensions: 1    Dimensions and sizes:   [DIM_000 | 281024]    Coordinates:    Number Of Attributes: 6      _FillValue :  -9999      coordinates : /Soil_Moisture_Retrieval_Data/latitude /Soil_Moisture_Retrieval_Data/longitude      long_name :   Representative soil moisture measurement for the Earth based grid cell.      units :       cm**3/cm**3      valid_max :   0.5      valid_min :   0.02
Please let me know if I should explain more.
I've used Dennis's suggestion, and it worked well. However may I know 2 extra points:1- I've tried to use attached script to get average from multiple files, but an error as below has occurred:
fatal:Dimension sizes of left hand side and right hand side of assignment do not match
fatal:["Execute.c":8637]:Execute: Error occurred at or near line 61 in file SPL2SMP_E_areaave_mod1.ncl

This error could be expected because of the below lines in loop:
    var = SPL2_E_f->$var_path$
    lat = SPL2_E_f->$lat_path$
    lon = SPL2_E_f->$lon_path$
    sm_avg(i)                    = avg(var(ism))

However using ":=" couldn't help so.May I ask help again about using above lines in loop.
2- May I ask how compute areal average of these data? I mean which function of ncl could help me about that (just for curiously!).
SincerelyEhsan
   On Monday, August 13, 2018, 8:23:47 AM GMT+4:30, Dennis Shea <shea at ucar.edu> wrote:  
 
 The data values on  'SMAP_L2_SM_P_E_*h5' are from satellite swaths. "L2"

The data variable ("soil_moisture") and the location variables: "latitude" and  "longitude" are all one-dimensional. It looks like the swath values and the associated latitude & longitude locations were just made into one-dimensional arrays. 

Your code comments the following:

/;
                            --37.80-----
                        |                       |
                   45.8                  46.03
                        |                       |
                            ---37.45----
;/

There is no need to perform and areal average when using such a small area [specifically such a small latitudinal range]. .The following should suffice:

       latS = 37.45
       latN = 37.80
       lonL = 45.8
       lonR = 4603

      sm    = f->soil_moisture   ; [*]
      lat     = f->latitude             ; [*]
      lon    = f->longitude          ; [*]

       ism = ind(.not.ismissing(sm) .and. lat.ge.latS   .and. lat.le.latN \
                                                       .and. lon.ge.lonL .and. lon.le.lonR)
       npts = dimsizes(ism)

       sm_avg = avg(sm(ism))
============================== ====================
Side points:

Alessandra's suggestions would be appropriate if the original data were on a rectilinear grid and then had been placed onto 1D arrays. Then, if you knew the appropriate nlat and mlon sizes you could have used

      xGrid = conform_dims( (/nlat,mlon/), x1d)   ; (nlat,mlon); similar to onedtond

===
The documentation for wgt_areaave should be clarified. This function expects a rectilinear grid.

======
On Sun, Aug 12, 2018 at 4:13 PM, alesall <alesall at iri.columbia.edu> wrote:


Hi Ehsan, 
can you reorganize your data so that it is 2-dimensional, in latitude and longitude?If your “var” measures something which varies in latitude and longitude, you need to figure out how the data in it is ordered/organized. Is the fastest dimension longitude or latitude?You can use functions like “onedtond” to break down a vector of length nlon x nlat into a matrix of dimensions nlon, nlat.And then assign names/values of latitude and longitude to the dimensions accordingly.
warm regards



-- 
Alessandra Giannini
IRI for Climate and Society - The Earth Institute at Columbia University
P.O. Box 1000, Palisades NY 10964-8000
phone/fax: +1 845 680-4473/4864 - email: alesall at iri.columbia.ed u

On Aug 12, 2018, at 3:16 PM, Ehsan Taghizadeh <ehsantaghizadeh at yahoo.com> wrote:
 Hi,I'm sorry to forward my question again! Do you think it is possible doing this or I should leave it?I'll be thankful for any suggestion.
SincerelyEhsan

   ----- Forwarded Message ----- From: Ehsan Taghizadeh <ehsantaghizadeh at yahoo.com>To: Ncl-talk <ncl-talk at ucar.edu>Sent: Thursday, August 2, 2018, 8:00:22 PM GMT+4:30Subject: area average
 Hi,I've tried to compute area average using "wgt_areaave". However it seems my data are 1 dimensional. So the following error occurred, as it is expected:      fatal:wgt_areaave: the input array must have at least 2 dimensions

Could I ask any help to have are average from 1 dimension data?!
I attached my script and put input files (SPL2SMP_E.tar) in ftp. Other information are: $ ncl -V     6.5.0$ uname -a     Linux localhost.localdomain 3.10.0-514.2.2.el7.x86_64 #1 SMP Tue Dec 6 23:06:41 UTC 2016 x86_64         x86_64 x86_64 GNU/Linux$ gcc --version     gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28)     Copyright (C) 2015 Free Software Foundation, Inc.
I'll be thankful for any help.

SincerelyEhsan  <SPL2SMP_E_areaave.ncl>_______ ______________________________ __________
ncl-talk mailing list
ncl-talk at ucar.edu
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailma n/listinfo/ncl-talk



______________________________ _________________
ncl-talk mailing list
ncl-talk at ucar.edu
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailma n/listinfo/ncl-talk



    
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180817/3a28d8bc/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 2018_04_01.jpg
Type: image/jpeg
Size: 374093 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180817/3a28d8bc/attachment-0001.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SPL2SMP_E_areaave_mod1.ncl
Type: application/octet-stream
Size: 3903 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180817/3a28d8bc/attachment-0001.obj>


More information about the ncl-talk mailing list