<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>The short answer is "no". There is no automatic method to do this. <br></div><div><br></div><div>However, 'brute force' can be used. It may be good to test on a 'few' files (eg; ntim=nfil=20)</div><div>If really slow; create a netCDF file and use that for subsequent analysis.</div><div>Each swath has different latitude/longitude arrays associated with it. <br></div><div>I speculate that these will be needed also.<br></div><div><br></div><div> <b>The following is not tested. </b><br></div><br> varname = "pr_dbz"<br><br> tStrt = <b>get_cpu_time</b>() ; timing information<br> .... ; your code to acces file names<br> nfil = <b>dimsizes</b>( fili )<br> ntim = nfil ; clarity; each 'file' corresponds to a different 'time'<br> <i><b>NSCAN = 50000 ; arbitrary large number</b></i><br> NRAY = 80 ; fixed<br><br> ntim = 20 ; for testing; override the original ntim=nfil</div><div dir="ltr"> ; quick turn around ; number is arbitrary<br><br> VAR = <b>new</b>((/ntim,NRAY,NSCAN/),"float") ; 'SUPER' variable<br> ;LAT = new((/ntim,NRAY,NSCAN/),"float") ; 'SUPER' variable<br> ;LON = new((/ntim,NRAY,NSCAN/),"float") ; 'SUPER' variable<br>;TIME = new( ntim, ???, "No_FillValue") ; integer, float, double ; recommended; create a time variable<br> nscan_max = -1<br><br> do nt=0,ntim-1 ; loop over each file (time)<br> f = <b>addfile</b>( fili(nt), "r")<br> x = f-><b>$</b>varname<b>$</b> ; (nray,nscan); integer?; why (::-1,:) ?<br> dimx = <b>dimsizes</b>(x)<br> nray = dimx(0)<br> nscan = dimx(1)<br> if (nray.ne.NRAY .or. nscan.gt.NSCAN) then<br> <b>print</b>("FATAL: unexpected array size: nray="+nray+": nscan="+nscan+": "+fili(nt))<br> exit<br> end if<br> nscan_max = <b>max</b>((/nscan_max,nscan/)) ; can be used to set NSCAN <br><br> VAR(nt,:,0:nscan-1) = <b>tofloat</b>( x )<br><br> ;time: create a 'time' variable ; this is optional but recommended<br> ;time = <b>cd_calendar</b>(.....)<br> ;TIME(nt) = time<br> ;LAT(nt,:,0:nscan-1) = (/ f->Latitude /)<br> ;LON(nt,:,0:nscan-1) = (/ f->Longitude /)<br> end do<br><br> VAR!0 = "time"<br>;;VAR&time = TIME<br> VAR!1 = "nray"<br> VAR&nray = <b>ispan</b>(1,NRAY,1) ; or <b> ispan</b>(0,NRAY-1,1)<br> VAR!2 = "NSCAN"<br> VAR&NSCAN = ispan(1,NSCAN,1) ; or ispan(0,NSCAN-1,1)<br> VAR@long_name = x@long_name<br> VAR@hdf_name = x@hdf_name<br> if (isatt(x,"units")) then<br> VAR@units = x@units<br> end if<br><br> <b>printVarSummary</b>(VAR)<br> <b>printMinMax</b>(VAR,0)<br> print("===")<br><br>; same approach for LAT (units: "degrees_north") and LON (units: degrees_east")<br><br> etime = <b>get_cpu_time</b>() -tStrt<br> print("Elapsed time: " + etime+" nfil="+nfil+": nscan_max="+nscan_max)<br> print("===")<br><br>;; Create a netCDF file using VAR<br><br> netCDF = True<br> if (netCDF) then<br> dirNc = "./"<br> filNc = "Super_"+varname+".1Z09.nc" ; whatever you want<br> pthNc = dirNc + filNc ; file path<br><br> system("/bin/rm -f "+pthNc) ; remove any pre-existing file<br><br> <b>setfileoption</b>("nc","Format","NetCDF4Classic") ; variable (likely) > 2GB<br> ncdf = addfile(pthNc ,"c") ; open output netCDF file<br><br>;===================================================================<br>; create global attributes of the file (optional)<br>;===================================================================<br> fAtt = True ; assign file attributes<br> fAtt@Title = "TRMM-PF: 1Z09: Super Variable: "+varname<br> fAtt@Number_of_files = nfil<br> fAtt@Conventions = "None"<br> fAtt@Creation_date = <b>systemfunc</b> ("date")<br> fileattdef( ncdf, fAtt ) ; copy file attributes<br><br>;===================================================================<br>; make time an UNLIMITED dimension; recommended for most applications<br>;===================================================================<br> <b>filedimdef</b>(ncdf,"time",-1,True<br>;===================================================================<br>; output variables directly; NCL will call appropriate functions<br>; to write the meta data associated with each variable<br>;===================================================================<br> var_super = varname_super<br> ncdf->$var_super$ = VAR ; (time,nray,NSCAN)<br> ;;ncdf->Latitude = LAT ; (time,nray,NSCAN)<br> ;;ncdf->Longitude = LON<br> end if ; netCDF<br><br></div></div></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Sat, Oct 6, 2018 at 7:48 PM Stefane Fonseca Freitas <<a href="mailto:fane.freitas@hotmail.com" target="_blank">fane.freitas@hotmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div id="m_7640351955046216481m_3582117923180442665m_381457386503498245m_2327165802896222648m_-8413597218620964495divtagdefaultwrapper" style="font-size:10pt;color:#000000;font-family:Arial,Helvetica,sans-serif" dir="ltr">
<p style="margin-top:0;margin-bottom:0"></p>
<p style="margin-top:0;margin-bottom:0">Hi users,</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"><span>I'm using TRMM precipitation features swath data. In this data, for each orbit, the variables size changes (dimensions number remains same) because only precipitation pixels are recording in the file. I want read
<span>reflectivity</span> profile in multiple files (~7000 files) using addfiles and join operation. I know that join requires that variables in each file must be the same size. So, my question is: is there a way to conform the dimension sizes of variables
while reading the files? Is it possible to read in NCL a variable with different dimension size in each file? Or any other suggestion how could I manipulate this variable as one file for statistical analysis?</span><br>
</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Script:</p>
<p style="margin-top:0;margin-bottom:0">;***********************************************************************************************************************************************************************************************<br>
</p>
<div><br>
<div>begin<br>
<br>
<br>
diri = "/media/stefaneff/Seagate\ Expansion\ Drive/TRMM-PF/199801/"<br>
<br>
<br>
cmd = "find "+ diri + "1Z09.* -type f -print"<br>
fili = systemfunc(cmd)<br>
<br>
nfil = dimsizes( fili ) <br>
<br>
varname="pr_dbz"<br>
<br>
<br>
f=addfiles(fili, "r")<br>
<br>
ListSetType (f, "join") <br>
<br>
<br>
var=int2flt(f[:]->$varname$(::-1,:))<br>
<br>
end</div>
</div>
<span>;***********************************************************************************************************************************************************************************************</span><br>
<p style="margin-top:0;margin-bottom:0">Error message:</p>
<div>warning:File /media/stefaneff/Seagate Expansion Drive/TRMM-PF/199801/1Z09.19980101.00545.7.HDF dimension sizes do not conform to others in list; skipping file<br>
warning:File /media/stefaneff/Seagate Expansion Drive/TRMM-PF/199801/1Z09.19980101.00544.7.HDF dimension sizes do not conform to others in list; skipping file<br>
warning:File /media/stefaneff/Seagate Expansion Drive/TRMM-PF/199801/1Z09.19980101.00543.7.HDF dimension sizes do not conform to others in list; skipping file<br>
warning:File /media/stefaneff/Seagate Expansion Drive/TRMM-PF/199801/1Z09.19980101.00542.7.HDF dimension sizes do not conform to others in list; skipping file<br>
warning:File /media/stefaneff/Seagate Expansion Drive/TRMM-PF/199801/1Z09.19980101.00541.7.HDF dimension sizes do not conform to others in list; skipping file<br>
warning:File /media/stefaneff/Seagate Expansion Drive/TRMM-PF/199801/1Z09.19980101.00540.7.HDF dimension sizes do not conform to others in list; skipping file<br>
warning:File /media/stefaneff/Seagate Expansion Drive/TRMM-PF/199801/1Z09.19980101.00539.7.HDF dimension sizes do not conform to others in list; skipping file<br>
warning:A valid instance of variable pr_dbz was not found in one or more elements of the file list<br>
fatal:Number of subscripts on rhs do not match number of dimensions of aggregated join type variable, (2) subscripts used, (3) subscripts expected<br>
fatal:["Execute.c":8637]:Execute: Error occurred at or near line 29 in file reflectivity_profile.ncl<br>
<br>
</div>
<span>;***********************************************************************************************************************************************************************************************</span><br>
<p style="margin-top:0;margin-bottom:0">PrintVarSummary of pr_dbz in one file: first dimension has always the same size (levels), second dimension not (lat,lon)</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<div>Variable: pr_profile<br>
Type: integer<br>
Total Size: 10451520 bytes<br>
2612880 values<br>
Number of Dimensions: 2<br>
Dimensions and sizes: [fakeDim6 | 80] x [fakeDim7 | 32661]<br>
Coordinates: <br>
Number Of Attributes: 2<br>
long_name : 2A25 REFLECTIVITY profiles (dBZ*100)<br>
hdf_name : pr_dbz<br>
<br>
</div>
<br>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Best regards,</p>
<br>
<p></p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<div id="m_7640351955046216481m_3582117923180442665m_381457386503498245m_2327165802896222648m_-8413597218620964495Signature">
<div id="m_7640351955046216481m_3582117923180442665m_381457386503498245m_2327165802896222648m_-8413597218620964495divtagdefaultwrapper" dir="ltr" style="font-size:12pt;color:rgb(0,0,0);font-family:Arial,Helvetica,sans-serif,"EmojiFont","Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<div><font face="Corbel, sans-serif" color="#ac193d"><span style="color:rgb(0,0,0);font-size:12pt;font-family:Arial,Helvetica,sans-serif">Stefane Fonseca Freitas</span></font></div>
<div><font face="Corbel, sans-serif" color="#ac193d"><b><br>
</b></font></div>
<div><font class="m_7640351955046216481m_3582117923180442665m_381457386503498245m_2327165802896222648m_-8413597218620964495ecxApple-style-span" face="Arial" color="#ac193d"></font><span style="color:rgb(0,0,0);font-size:10pt;font-family:Arial,Helvetica,sans-serif"></span>
<div><font face="Arial" color="#ac193d"><font style="font-size:15px" face="tahoma, sans-serif" color="#0000ff"><span style="color:rgb(0,0,0);font-size:10pt;font-family:Arial,Helvetica,sans-serif">Doutoranda
</span><span style="color:rgb(0,0,0);font-size:10pt;font-family:Arial,Helvetica,sans-serif">em Meteorologia</span><span style="color:rgb(0,0,0);font-size:10pt;font-family:Arial,Helvetica,sans-serif"> - </span></font></font><span style="color:rgb(0,0,0);font-family:Arial,Helvetica,sans-serif;font-size:10pt">PGMET
- CPTEC / INPE</span><font face="Arial" color="#ac193d">
<div style="color:rgb(33,33,33);font-size:15px">
<div><font face="tahoma, sans-serif" color="#0000ff">
<div dir="ltr"><span style="color:rgb(0,0,0);font-size:10pt;font-family:Arial,Helvetica,sans-serif">Centro de Previsão de Tempo e Estudos Climáticos / Instituto Nacional de Pesquisas Espaciais</span></div>
<span style="color:rgb(0,0,0);font-size:10pt;font-family:Arial,Helvetica,sans-serif">Cachoeira Paulista - SP - Brasil</span></font></div>
<div><br>
<span style="font-family:tahoma,sans-serif;font-size:12.8px;color:rgb(0,0,0)"></span></div>
</div>
</font></div>
<div><font face="Arial" color="#ac193d"></font></div>
</div>
</div>
</div>
</div>
</div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
</blockquote></div>