[ncl-talk] Hourly mean csv file

Toni Klemm toni-klemm at tamu.edu
Wed Aug 8 12:08:37 MDT 2018


Hi Mauro,

I’m not very familiar with processing csv files in NCL, but have you tried using loops for hour, day, month, and year, and reading in multiple files based on their file names, e.g., all files with the file name structure "yyyy mm dd hh1 AOD”? That way all files should get read in, regardless of the number. Here is what I would do if the files were in .nc format:

do year = [from],[to]			; years always have four digits

  do month = 1,12

    if (month .lt. 10) then
      month_zero = "0" + month		; turns "1"..."9" into "01"..."09" to match filename structure
    end if

    if(month .gt. 9) then
      month_zero = month		; leave “10”..."12" unchanged
    end if

    do day = 1,31

      if (day .lt. 10) then
        day_zero = "0" + day		; turns "1"..."9" into "01"..."09" to match filename structure
      end if

      if(hour .gt. 9) then
        day_zero = day			; leave "10…"31" unchanged
      end if

      do hour = 0,23

        if (hour .lt. 10) then
          hour_zero = "0" + hour	; turns "1"..."9" into "01"..."09" to match filename structure
        end if

        if(hour .gt. 9) then
          hour_zero = hour		; leave "10…"23" unchanged
        end if
     

       AOD_files = systemfunc("ls ~/your/file/directory/" + year + "/" + month_zero + "/" + day_zero + "/" + hour_zero + “_AOD.csv")
       AOD_f = addfiles(AOD_files,"r")
       ListSetType(MC2_f,"cat”)


...
proceed with your analysis, e.g., dim_avg_n
...


      end do
    end do
  end do
end do



Hope that helps.

Toni


Toni Klemm, Ph.D.
Postdoctoral Research Associate
Department of Ecosystem Science and Management
College of Agriculture and Life Sciences
Texas A&M University, College Station, TX
Contributor at the Early Career Climate Forum <http://www.eccforum.org/>
www.toni-klemm.de <http://www.toni-klemm.de/> | @toniklemm <http://twitter.com/toniklemm>







> On Aug 8, 2018, at 12:41 PM, Mauro Morichetti <s1073755 at pm.univpm.it> wrote:
> 
> Hi all,
> 
> based on the object, I am comparing a different wrfout with some AEREONET AOD data.
> 
> The AOD data are in csv format:
> 
> yyyy mm dd hh1 AOD
> yyyy mm dd hh1 AOD
> yyyy mm dd hh1 AOD
> …..
> yyyy mm dd hh2 AOD
> yyyy mm dd hh2 AOD
> yyyy mm dd hh2 AOD
> ….
> 
> 
> The values per hour have not the same interval (one hour can have 3 values and the other one can have 5 values etc.). 
> 
> I should need the hourly mean in order to compare with the wrfoutput, but I can not figure out how to solve the problem, any suggestions?
> 
> Thanks,
> 
> Mauro
> ---------
> 
> Eng. Mauro Morichetti
> Department of Industrial Engineering and Mathematical Science
> Marche Polytechnic University, Ancona, Italy
> m.morichetti at pm.univpm.it <mailto:m.morichetti at pm.univpm.it>
> _______________________________________________
> ncl-talk mailing list
> 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/20180808/477d4eff/attachment.html>


More information about the ncl-talk mailing list