so, i'm using function this website (try) make stick plots of netcdf4
data. there excerpt of code below. got data here.
the stick_plot(time,u,v)
function appears in website linked why did not show copy of function below.
when run code following error. idea on how around this?
attributeerror: 'numpy.float64' object has no attribute 'toordinal'
the description of time netcdf4
file:
<type 'netcdf4._netcdf4.variable'> float64 time(time) long_name: time standard_name: time units: days since 1900-01-01 00:00:00z axis: t ancillary_variables: time_quality_flag data_min: 2447443.375 data_max: 2448005.16667 unlimited dimensions: current shape = (13484,) filling off
here excerpt of code:
imports:
import matplotlib.pyplot plot import numpy np netcdf4 import dataset import os matplotlib.dates import date2num datetime import datetime
trying generate plots:
path = '/users/kyle/documents/summer_research/east_coast_currents/' currents = [x x in os.listdir('%s' %(path)) if '.ds' not in x] datum in currents: working_data = dataset('%s' %(path+datum), 'r', format = 'netcdf4') u = working_data.variables['u'][:][:100] v = working_data.variables['v'][:][:100] time = working_data.variables['time'][:][:100] q = stick_plot(time,u,v) ref = 1 qk = plot.quiverkey(q, 0.1, 0.85, ref, "%s n m$^{-2}$" % ref, labelpos='n', coordinates='axes') _ = plot.xticks(rotation=70)
joe kington answered question. netcdf4 file read times in datetime
object. had replace date2num(time)
time
fixed everything.
Comments
Post a Comment