[ncl-talk] loop_query

Yuqiang Zhang yuqiangzhang.thu at gmail.com
Fri Mar 31 18:12:32 MDT 2017


Hi Kunal,

 

I think you really need to read this before you post further questions:

Mini-Language Reference Manual

https://www.ncl.ucar.edu/Document/Manuals/language_man.pdf

 

It’s really not a good idea to ask others from this forum to debug simple errors/bugs for you. NCL has an easy-to-follow webpage and also excellent example. Please do spend some time to take advantage of them. 

 

People get a lot of help and comments on how to improve their work efficiencies from this forum. Please help but not ruin it! 

 

Take care! 

 

Regards,

Yuqiang

 

From: ncl-talk-bounces at ucar.edu [mailto:ncl-talk-bounces at ucar.edu] On Behalf Of Kunal Bali
Sent: Friday, March 31, 2017 2:55 PM
Cc: ncl-talk at ucar.edu
Subject: Re: [ncl-talk] loop_query

 

Thanks Dennis for all the information and the help. 




Kunal Bali

Research Scholar 

Radio & Atmospheric Science Division 

CSIR - National Physical Laboratory

New Delhi - 110012

India

 

 

 

 

 

On Sat, Apr 1, 2017 at 12:05 AM, Dennis Shea <shea at ucar.edu <mailto:shea at ucar.edu> > wrote:

Variable: data
Number of Dimensions: 3
Dimensions and sizes:    [time | 30] x [latitude | 330] x [longitude | 300]

Dimension numbers:               0                       1                           2

-----

So the following are pointing to the *wrong* dimensions

  lat1d = ndtooned(conform(data,data&latitude,0))       ; 0 is 'time'
  lon1d = ndtooned(conform(data,data&longitude,1))   ; 1 is 'lat'

the following is suggested

  lat1d = ndtooned(conform(data,data&latitude,1))
  lon1d = ndtooned(conform(data,data&longitude,2))

====

Several manual describe dimension numbering but the following sentence is most succinct

"Dimension numbering proceeds from left-to-right with the leftmost dimension equal to 0.{

  (time)   ; 0

  (lat)      , 0

  (time,npts);  time=0 , npts=1

  (time,lat,lon)  ; 0, 1, 2

  (time,lev,lat,lon);   0, 1, 2, 3

  (nensemble,time, lev,lat,lon)   ; 0, 1, 2, 3, 4

 

 

On Fri, Mar 31, 2017 at 12:14 PM, Kunal Bali <kunal.bali9 at gmail.com <mailto:kunal.bali9 at gmail.com> > wrote:

I apologize from the deep of my heart. I didn't mean to bother you. 

actually

The script is reading all the 30 days files. 

Variable: data
Type: float
Total Size: 11880000 bytes
            2970000 values
Number of Dimensions: 3
Dimensions and sizes:    [time | 30] x [latitude | 330] x [longitude | 300]
Coordinates: 
            time: [913824..914520]
            latitude: [37.95..5.05]
            longitude: [68.05..97.95]
Number Of Attributes: 3
  long_name :    Wildfire flux of Black Carbon



It showing an error 

fatal:conform: the dimensions sizes of the second argument do not match those indicated by the third argument
fatal:["Execute.c":8578]:Execute: Error occurred at or near line 146 in file kunal.ncl

The error line are
  lat1d = ndtooned(conform(data,data&latitude,0))
  lon1d = ndtooned(conform(data,data&longitude,1))

I tried to find to find this answer but I could not find it. I am sorry if i am bothering you again.

 








Kunal Bali

Research Scholar 

Radio & Atmospheric Science Division 

CSIR - National Physical Laboratory

New Delhi - 110012

India

 

 

 

 

 

On Fri, Mar 31, 2017 at 11:20 PM, Dennis Shea <shea at ucar.edu <mailto:shea at ucar.edu> > wrote:

I still find your question and the code confusing.

It takes time to look at code and determine what is happening. It is your responsibility to pose clear questions and, if appropriate, a clean, minimal script that illustrates the issue(s). We answer questions on a volunteer basis. Our time is valuable too! You must help us help you!

Please read the addfiles and adfiles documentation.

http://www.ncl.ucar.edu/Document/Functions/Built-in/addfiles.shtml
http://www.ncl.ucar.edu/Document/Functions/Built-in/addfile.shtml

With addfiles ... please look at examples 1 and 2. 

Note the difference between 'cat' (the default) and 'join' (alternate approach) 

 

---

Create a script that contains *only* this part of your code. 

 

;---Read var1 
      dir    = "/home/kunal/"
      fnames = systemfunc("ls " + dir + "DAY_*.nc")

      print(fnames)
      nfil = dimsizes(fnames)
      print("nfil="+nfil)

      print("---")

      
       a      = addfiles(fnames,"r")
       data = a[:]->bcfire(0,:,:)        ; only one timestep

       printVarSummary(data)        ; *****look at the structure ****  and sizes 

 

   DATA = a[:]->bcfire
   printVarSummary(data)  ; *****look at the structure ****   
DATA should have something like (time,lat,lon) where 
dimsizes(time) >1


 
 

 

 

 

On Fri, Mar 31, 2017 at 11:01 AM, Kunal Bali <kunal.bali9 at gmail.com <mailto:kunal.bali9 at gmail.com> > wrote:

Sorry for creating the confusion. 

I changed the script as you suggested me and then run the attached script. But after running this, I am getting the file only of the single day instead of all 30 files separately. 

 




Kunal Bali

Research Scholar 

Radio & Atmospheric Science Division 

CSIR - National Physical Laboratory

New Delhi - 110012

India

 

 

 

 

 

On Fri, Mar 31, 2017 at 10:15 PM, Mary Haley <haley at ucar.edu <mailto:haley at ucar.edu> > wrote:

Kunal,

 

I'm a little confused by what you are asking for.  You said you wanted to extract all 30 days of data instantly, which is what the previous "addfiles" example was meant to show.  You don't need a loop to extract all the data.

 

Did you actually try my suggestion of changing your script to use "addfiles" instead of "addfile"?  If so, and you are still having a problem, then it would help to see the new version of your script.

 

Maybe my confusion is with what you want to do with the data after you extract all 30 days of data. Please be more specific if possible.

 

Thanks,

 

--Mary

 

 

On Thu, Mar 30, 2017 at 10:19 PM, Kunal Bali <kunal.bali9 at gmail.com <mailto:kunal.bali9 at gmail.com> > wrote:

Dear Mary,

Thanks for the suggestions. 

But still, it's extracting one file at a time, not extracting all the 30-day files separately of UK and NEP (as mentioned in the script). 

 




Kunal Bali

 

 

 

 

 

On Fri, Mar 31, 2017 at 3:09 AM, Mary Haley <haley at ucar.edu <mailto:haley at ucar.edu> > wrote:

Kunal,

 

You should be able to use "addfiles" to open all your files, and then read your data using the special [:] syntax:

 

  dir    = "/home/kunal/"

  fnames = systemfunc("ls " + dir + "DAY_*.nc")

  a      = addfiles(fnames,"r")
  data = a[:]->bcfire

 

For more information see our addfiles examples page:

 

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

 

--Mary

 

 

 

 

 

 

On Thu, Mar 30, 2017 at 12:42 PM, Kunal Bali <kunal.bali9 at gmail.com <mailto:kunal.bali9 at gmail.com> > wrote:

Dear NCL users



I have the data of 30 days. I want to extract this data with the loop.The attached script is based on to extract the data of a single day. So it's a tedious job to extract all the 30 days data one by one. So could anyone tell me that how to start the loop in the attached file so the I can get 30 days extracted data instantly. 

Thank You

Regards


Kunal Bali

 

 

 

 

 

_______________________________________________
ncl-talk mailing list
ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu> 
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

 

 


_______________________________________________
ncl-talk mailing list
ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu> 
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

 

 


_______________________________________________
ncl-talk mailing list
ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu> 
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

 

 


_______________________________________________
ncl-talk mailing list
ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu> 
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170331/ae3b2716/attachment.html 


More information about the ncl-talk mailing list