<div dir="ltr">I am trying to generate a 4 dimensional netcdf file with time, level, latitude, longitude from the the files on website:<br><br><a href="http://nomads.ncep.noaa.gov:9090/dods/rtofs/rtofs_global20141116/rtofs_glo_3dz_forecast_daily_uvel">http://nomads.ncep.noaa.gov:9090/dods/rtofs/rtofs_global20141116/rtofs_glo_3dz_forecast_daily_uvel</a><br><br clear="all"><div><br></div><div>for zonal ocean current velocities at different depths through python scripts.<br><br></div><div>I have the following python script but alas it is not allowing me to generate the desired netcdf file:<br><br>#!/usr/bin/python<br>from pydap.client import open_url<br>from datetime import *<br>import datetime<br>now = datetime.datetime.now()<br>import pickle<br>import pupynere<br>import shutil<br><br>datasetu = open_url(&#39;<a href="http://nomads.ncep.noaa.gov:9090/dods/rtofs/rtofs_global&#39;+now.strftime(">http://nomads.ncep.noaa.gov:9090/dods/rtofs/rtofs_global&#39;+now.strftime(</a>&quot;%Y%m%d&quot;)+&#39;/rtofs_glo_3dz_forecast_daily_uvel&#39;)<br>datasetv = open_url(&#39;<a href="http://nomads.ncep.noaa.gov:9090/dods/rtofs/rtofs_global&#39;+now.strftime(">http://nomads.ncep.noaa.gov:9090/dods/rtofs/rtofs_global&#39;+now.strftime(</a>&quot;%Y%m%d&quot;)+&#39;/rtofs_glo_3dz_forecast_daily_vvel&#39;)<br><br>#sst = dataset[&#39;sst&#39;]<br>#sst.shape<br>#h=0<br>#for t in sst.time[:]:<br>    # print h<br>#    datestr=str(date.fromordinal(int(t)))<br>#    hour=int(24*(t-int(t)))<br>#    hourstr=str(hour);<br>#    if(hour&lt;10): hourstr=&#39;0&#39;+hourstr<br>#    w=datestr.split(&#39;-&#39;)<br>#    w.append(hourstr)<br>#    filename = w[0] + w[1] + w[2] + w[3] + &#39;sst.pickle&#39;<br>#    if((int(w[3])%12)==0):     <br>#        print h,filename<br>#        f = open(filename,&#39;wb&#39;)<br>#        sgrd=sst.sst[h,0]<br>#        pickle.dump(sgrd,f)<br>#        f.close()<br>#    h=h+1<br><br>u = datasetu[&#39;u&#39;]<br>l = u.lat<br>lo = u.lon<br>le = u.lev<br>print u.shape<br>print l.shape<br>print lo.shape<br>print le.shape<br><br>f=open(&quot;lats.pickle&quot;,&quot;wb&quot;)<br>pickle.dump(l[428:430],f)<br>f.close<br><br>f=open(&quot;lons.pickle&quot;,&quot;wb&quot;)<br>pickle.dump(lo[2028:2030],f)<br>f.close<br><br>f=open(&quot;levs.pickle&quot;,&quot;wb&quot;)<br>pickle.dump(le[1:5],f)<br>f.close<br><br>f = pupynere.netcdf_file(&quot;<a href="http://hycom.nc">hycom.nc</a>&quot;,&#39;w&#39;)<br>f.createDimension(&quot;latitude&quot;,2)<br>f.createDimension(&quot;longitude&quot;,2)<br>f.createDimension(&quot;level&quot;,4)<br><br>lats=f.createVariable(&quot;latitude&quot;,&quot;f&quot;,(&quot;latitude&quot;,))<br>lats[:]=l[2028:2030]<br>lons=f.createVariable(&quot;longitude&quot;,&quot;f&quot;,(&quot;longitude&quot;,))<br>lons[:]=lo[428:430]<br>levs=f.createVariable(&quot;level&quot;,&quot;f&quot;,(&quot;level&quot;,))<br>levs[:]=le[1:5]<br><br>h=0<br>print &quot;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;U Velocity&quot;<br>for t in u.time[:]:<br>    datestr=str(date.fromordinal(int(t)))<br>    hour=int(24*(t-int(t)))<br>    hourstr=str(hour);<br>    if(hour&lt;10): hourstr=&#39;0&#39;+hourstr<br>    w=datestr.split(&#39;-&#39;)<br>    w.append(hourstr)<br>#    filename= w[0] + w[1] + w[2] + w[3] + &#39;u.pickle&#39;<br>    if((int(w[3])%12)==0):<br>#        print h,filename<br>#        f = open(filename,&#39;wb&#39;)<br>        #print u.u[h,1:5,428:430,2028:2030]<br>        ugrd = f.createVariable(&quot;ugrd&quot;,&quot;f&quot;,(&quot;level&quot;,&quot;latitude&quot;,&quot;longitude&quot;))<br>        ugrd = u.u[h,1:5,428:430,2028:2030]<br>        print ugrd<br>#        u[:] = ugrd<br>#        ugrd.units = &quot;m/s&quot;        <br>#        ugrd=u.u[h,0]<br>#        pickle.dump(u.u[h,1:5,428:430,2028:2030],f)<br>#        f.close()<br>    h=h+1<br><br><br><br></div><div>Anyway suggestions?<br><br><br></div><div>Thanks,<br><br>Jason<br></div><div><br></div></div>