RE: [ncl-talk] read AERONET data

From: Lin Su <Lin.Su_at_nyahnyahspammersnyahnyah>
Date: Wed, 8 Aug 2007 10:10:11 -0600 (MDT)

Thanks a lot, Mary:)

I have to say I learned a lot from this list, and NCL is fantastic to handle all kinds of scientific questions!

Talk later,
-Lin

---- Original message ----
>Date: Tue, 7 Aug 2007 16:50:18 -0600 (MDT)
>From: Mary Haley <haley_at_ucar.edu>
>Subject: RE: [ncl-talk] read AERONET data
>To: Lin Su <Lin.Su_at_colorado.edu>
>Cc: ncl-talk_at_ucar.edu
>
>
>Hi Lin,
>
>Please see the attached test2.ncl script. It shows how to read
>a particular field from your field, given the "," as a delimeter.
>It also knocks of the first four lines, since these are headers.
>
>The function "get_field" is what I've added to your script, and it
>will return field you are interested in as an array of strings.
>You can then use "stringtofloat" to convert the strings to float.
>
>--Mary
>
>
>On Tue, 7 Aug 2007, Lin Su wrote:
>
>>
>> Dear all,
>>
>> I just printed aod5 & day5, and I found they are totally wrong. So the problem is maybe not the plot issue. I just don't know how to read AERONET data for each column using NCL correctly since the data including colon, N/A, etc. although I think each column is seperated by comma sign.
>>
>> Thanks a lot,
>> -Lin
>>
>>> -----Original Message-----
>>> From: ncl-talk-bounces_at_ucar.edu [mailto:ncl-talk-bounces_at_ucar.edu] On Behalf
>>> Of Lin Su
>>> Sent: Tuesday, August 07, 2007 11:34 AM
>>> To: ncl-talk_at_ucar.edu
>>> Subject: read AERONET data
>>>
>>> Dear all,
>>>
>>> My two previous problems have been resolved with Debasish and Dennis's great
>>> help! Now I got one more problem here: I supposed to read AERONET data for
>>> 400 values both for the Julian days (column3) and AOT_500 (column13), and by
>>> using printVarSummary, they look like just what I need. However, in my plot,
>>> it only shows around 10 points up instead of 400 points. Any trick here?
>>> Attched please find the ncl code (test.ncl), the plot (test.pdf). I will
>>> send the txt data (167k) to you as needed since I can't attach here due to
>>> the message body limit.
>>>
>>> BTW, I am preparing my COMPSII exam at the moment, and so sorry to bother
>>> all of you that much!
>>>
>>> Thanks again,
>>> -Lin
>>>
>>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk_at_ucar.edu
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>________________
>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>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/shea_util.ncl"
>
>;
>; This function takes a list of strings, and picks off a particular field
>; given the delimiter. Also, the number of header lines to skip can be
>; included.
>;
>function get_field(a[*]:string,nfield:integer,delimiter:string,nhead:integer)
>local nstrings, ibeg, iend, i, c, nc, dcount, j, anew
>begin
> anew = a(nhead:) ; Skip the first nhead lines.
> nstrings = dimsizes(anew)
>;
>; Loop through each string, find the nfield-th field, given
>; the delimiter. Ignore the first nhead strings; these are
>; just headers.
>;
> ibeg = 0 ; Begin and end of field to read.
> iend = 0
> do i=0,nstrings-1
> c = stringtochar(anew(i)) ; Convert to char array
> nc = dimsizes(c)-2 ; Don't include null char at end
> dcount = 0 ; Counter for # of delimeters found so far
> j = 0 ; Counter for string length
> do while(j.le.nc.and.dcount.lt.nfield)
> if(chartostring(c(j)).eq.delimiter) then
> dcount = dcount + 1
> if(dcount.eq.(nfield-1)) then
> ibeg = j+1 ; Start of nfield-th field
> end if
> if(dcount.eq.nfield) then
> iend = j-1 ; End of nfield-th field
> end if
> end if
> j = j + 1
> end do
> if(dcount.eq.nfield)
> anew(i) = chartostring(c(ibeg:iend))
> end if
> delete(c)
> end do
> return(anew)
>end
>
>begin
> path = "/Volumes/Data/Models/cam/AOD/aeronet/"
> path = "./"
> fileHandle5= path + "test.txt"
>;
>; Read data as strings, pick off the fields you want,
>; and convert to float.
>;
> DUSTAOD5 = asciiread(fileHandle5, -1, "string")
> day5 = stringtofloat(get_field(DUSTAOD5,3,",",4))-90. ; Read 3rd field
> aod5 = stringtofloat(get_field(DUSTAOD5,13,",",4)) ; Read 13th field
>
>; Make sure values look okay.
> printVarSummary(day5)
> printVarSummary(aod5)
> print("min/max day5 = " + min(day5) + "/" + max(day5))
> print("min/max aod5 = " + min(aod5) + "/" + max(aod5))
>
> delete(path)
>
>; plotting
>print("plotting")
> wks = gsn_open_wks("pdf", "test")
>
> res1 = True
> ;res1_at_xyMarkLineModes = "Marklines"
> res1_at_xyMarkLineModes = "Markers"
> res1_at_xyMarkers = 3
> res1_at_xyMarkerSizeF = 0.01
> res1_at_xyLineThicknesses = 2.0
> res1_at_xyLineColors = "black"
> res1_at_pmLegendDisplayMode = "Always" ; turn on legend
> res1_at_pmLegendSide = "Top" ; Change location of
> res1_at_pmLegendParallelPosF = .6 ; move units right
> res1_at_pmLegendOrthogonalPosF = -0.28 ; move units down
> res1_at_pmLegendWidthF = 0.15 ; Change width and
> res1_at_pmLegendHeightF = 0.03 ; height of legend.
> res1_at_lgPerimOn = False ; turn off box around
> res1_at_lgTitleFontHeightF = .018
> res1_at_lgLabelFontHeightF = .015 ; label font height
> res1_at_xyExplicitLegendLabels = (/"AERONET","ustar"/)
> res1_at_tiXAxisString = "days in April 2001"
> res1_at_tiYAxisString = "AOD[500nm] "
> res1_at_tmLabelAutoStride = True
> res1_at_trXLog = False
> res1_at_trYLog = False
> res1_at_trXMinF = 0.0
> res1_at_trXMaxF = 30
> res1_at_trYMinF = 0.0
> res1_at_trYMaxF = 6.0
>
> plot = gsn_csm_xy(wks, day5, aod5, res1)
>
> end
Received on Wed Aug 08 2007 - 10:10:11 MDT

This archive was generated by hypermail 2.2.0 : Thu Aug 09 2007 - 10:59:25 MDT