1 / 9

MyOcean Ferrybox with Python

MyOcean Ferrybox with Python. Requirements. Python 2.7 netCDF4 Ipython Numpy Scipy Matplotlib Basemap All can be found in Python( x,y ) for Windows. Imports. import datetime import netCDF4 import numpy as np import matplotlib.pyplot as plt. Read netCDF.

candra
Download Presentation

MyOcean Ferrybox with Python

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MyOcean Ferrybox with Python Pierre Jaccard

  2. Requirements • Python 2.7 • netCDF4 • Ipython • Numpy • Scipy • Matplotlib • Basemap • All can be found in Python(x,y) for Windows Pierre Jaccard

  3. Imports import datetime import netCDF4 import numpy as np import matplotlib.pyplot as plt Pierre Jaccard

  4. Read netCDF ncf = '../Data/GO_LATEST_TS_FB_ColorFantasy_20130607.nc' nc = netCDF4.Dataset(ncf, 'r') nc.variables.keys() t = nc.variables['TIME'] T = nc.variables['TEMP'][:] Pierre Jaccard

  5. Calculate Time t = nc.variables['TIME'] t0 = datetime.datetime(1950, 1, 1) dt = np.array(map(lambda x: datetime.timedelta(days=x), t)) t1 = t0 + dt Pierre Jaccard

  6. Plot Temperature I T = nc.variables['TEMP'][:] plt.figure() plt.plot(t1, T, 'b-') plt.grid(True) plt.show() Pierre Jaccard

  7. Quality Flags qcT= nc.variables['TEMP_QC'][:,0] qct = nc.variables['TIME_QC'][:] qcp = nc.variables['POSITION_QC'][:] qcm = (qcT > 0) & (qcT < 3) & (qct > 0) & (qct < 3) & (qcp > 0) & (qcp < 3) np.any(qcm) np.all(qcm) Pierre Jaccard

  8. Plot Temperature II plt.figure() plt.hold(True) plt.plot(t1[qcm], T[qcm], 'g.') plt.plot(t1[~qcm], T[~qcm], 'r.') plt.grid(True) plt.show() Pierre Jaccard

  9. FTP import ftplib host = 'vftp1.ifremer.fr' path = '/INSITU_GLO_NRT_OBSERVATIONS_013_030/' ftp = ftplib.FTP(host) ftp.login(user, passwd) ftp.cwd(path) fd = open(local, 'wb') self.ftp.retrbinary("RETR " + remote, fd.write) fd.close() ftp.close() Pierre Jaccard

More Related