comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Assimilating three files considering their DOY and overpassing time
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Assimilating three files considering their DOY and overpassing time [message #55248] Thu, 09 August 2007 10:30
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
Hi,

Use OPENU instead of OPENW .... the former updates the file while the
later replaces it...

Jean

DirtyHarry wrote:
> G'day, Everyone...!
>
> I made a souce code. It just runs without error messages, but it's not
> yet working properly.
>
> What I am trying to do now is to assimilate two files based on its day
> of year (DOY) and overpassing time (Time).
> In order to do this... I...
>
> 0) prepared an array: total_array = fltarr(13, num_MYD07)
> Column 1~9 : for MYD07
> Column 10~11 : for MYD04
> Column 12~13 : for MCD43
>
> 1) compared the DOY and overpassing time between three data files.
> 1.1) Read MYD07 first because this file has the largest number of
> lines among three.
> 1.2) Then read MYD04 and compare DOY and Time between them.
> - If the contents of DOY and Time of those two files are
> identical -> then add MYD04 values into column 10 and 11.
> If they are different, then add -99.99 to each column.
> 1.3) Do the same for MCD43 into column 12 and 13.
> 2) made an output file.
>
> I coded as shown below. Currently the biggest problem is that IDL only
> print the last line into the designated output file.
>
> Please take a look at this code and give my any comments/suggestions.
> Thank you in advance.
>
> Harry
>
> ------------------------------------------------------------ -
>
> pro Match_MYD_080907 ; using readcol
>
> close, /all
> WorkDir = 'D:\OUTPUT\Site72\'
> site_num = 72
>
> for id=0, 3 do begin ;site_num-1 do begin
>
> ;---------------------------
>
> ;=============================
> ;Counting the number of lines
> ;=============================
> MYD07 = strcompress(WorkDir + 'MYD07_all_data_TEST_' + string(fix(id
> +1)) + '.txt',/remove_all)
> MYD04 = strcompress(WorkDir + 'MYD04_output0801_' + string(fix(id+1))
> + '.txt',/remove_all)
> MCD43 = strcompress('D:\MODIS_ALL\MCD43_output_' + string(fix(id+1)) +
> '.txt',/remove_all)
>
> num_MYD07 = file_lines(MYD07)
> num_MYD04 = file_lines(MYD04)
> num_MCD43 = file_lines(MCD43)
> ;output file
> MYD_match = strcompress('MYD_match_TEST' + string(fix(id+1)) + '.txt',/
> remove_all)
>
> Readcol, MYD07, format='I, I, I, F, X, F, F, F, F, I', year, doy,
> time, Ta, OZ, PTOT, PWC, SOLZA, ClearPix
> Readcol, MYD04, format='A, F, F, F', FileName04, AOT1, AOT2, AOT3
> Readcol, MCD43, format='A, F, F', FileName43, bsa, wsa
>
> ; =================== The contents of each input file
> =================================
>
> ; MYD07 -
> ; year(int:0), doy(int:1), time(int:2), Ta(flt:3), Ea(flt:4), oz(flt:
> 5), ptot(flt:6),pwc(flt:7),solza(flt:8), clearPix(9), $
> ; year(0, doy, time+900, Ta, Ea OZ, PTOT
> PWC, SOLZA ClearPix
> ;
> ; MYD04 -
> ; filename(Str:0), AOT1(Flt:1), AOT1(Flt:2), AOT1(Flt:3)
> ;
> ;MCD43 -
> ; filename(Str:0), bsa(Flt:1), wsa(Flt:2)
> ;
> ;
> ============================================================ ===============
>
> total_array = fltarr(13, num_MYD07)
> for i=0, num_MYD07-1 do begin
> openw, write_lun, MYD_match, /Get_Lun
> total_array[0, i] = year[i]
> total_array[1, i] = DOY[i]
> total_array[2, i] = time[i]
> total_array[3, i] = Ta[i]
> total_array[4, i] = Oz[i]
> total_array[5, i] = PTOT[i]
> total_array[6, i] = PWC[i]
> total_array[7, i] = Solza[i]
> total_array[8, i] = ClearPix[i]
>
> check1 = 0
> check2 = 0
>
> for k=0, num_MYD04-1 do begin
> if (DOY[i] eq strmid(FileName04[k],9,11)) and (Time[i] eq
> (strmid(FileName04[k], 13, 16))+900) then begin
> total_array[ 9,i] = AOT1[k]
> total_array[10,i] = AOT2[k]
> check1=1
>
> endif
> endfor
> if check1 eq 0 then begin
> total_array[ 9,i] = -99.99
> total_array[10,i] = -99.99
>
> endif
> check1=0
>
> for j = 0, num_MCD43-1 do begin
> if (DOY[i] eq strmid(FileName43[j],9,11)) and (Time[i] eq
> (strmid(FileName43[j],13,16))+900) then begin
> total_array[11,i] = bsa[j]
> total_array[12,i] = wsa[j]
> check2=1
>
> endif
> endfor
> if check1 eq 0 then begin
> total_array[11,i] = -99.99
> total_array[12,i] = -99.99
> endif
> check2 = 0
>
> ; year(int:0), doy(int:1), time(int:2), ta(flt3), oz(flt:4), ptot(flt:
> 5),pwc(flt:6),solza(flt:7), clearPix(int:8), $
> ; aot1(flt:9),aot2(flt:10), bsa,(flt:11), wsa(flt:12)
>
> printf, write_lun, format='(3(F7.1, 2x), 5(F9.2, 2X), F3.1,
> 2x, 4(F8.2, 2X))', total_array[0:12,i]
> Free_lun, write_lun
> endfor
>
> endfor
> print, "It's OK!'
>
> end
>
[Message index]
 
Read Message
Previous Topic: Re: Mac OS x IDL font handling
Next Topic: Re: .lib C routines in IDL

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 14:17:17 PDT 2025

Total time taken to generate the page: 1.04051 seconds