def preview(self): '''Preview map in window''' theurl = self.FILENAME.get() if empty(theurl): messagebox.showinfo(message='No image selected') return self.ax1.clear() print('Preview of ',theurl) icdf = Dataset(theurl,'r') lon = icdf.variables['lon'][:] lat = icdf.variables['lat'][:] sst = icdf.variables['mcsst'][0,:,:].squeeze() xxT,yyT = np.meshgrid(lon,lat) SOUTH = np.min(lat) NORTH = np.max(lat) WEST = np.min(lon) EAST = np.max(lon) m = Basemap(llcrnrlat=SOUTH,urcrnrlat=NORTH, \ llcrnrlon=WEST,urcrnrlon=EAST, \ ax=self.ax1) m.fillcontinents(color='coral') m.drawcoastlines(linewidth=1) m.contourf(xxT,yyT,sst) self.canvas.draw() print('done')
def filename(self, PATH): #======================= nmonth = [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ] # Get the selected hour: value_selected = self.hourbox.get() if (empty(value_selected)): messagebox.showinfo(message='No image selected') theurl = '' return theurl else: for ind, name in enumerate(self.SEL): if name == value_selected: thesat = self.SAT[ind] year = self.YEAR.get() month = self.MONTH.get() day = self.DAY.get() hour = self.hour_var.get() theurl = PATH + str(year) + '/' + '%02d-' % month + nmonth[ month - 1] + '/%02d/' % day + str( year) + '%02d' % month + '%02d' % day + '.' + hour[0:2] + hour[ 3:5] + '.' + thesat + '.nc' return theurl
def done(self): '''Gets the selected options and gets the corresponding URL before closing the app. The URL is saved in self.FILENAME''' if empty(self.FILENAME.get()): messagebox.showinfo(message='No image selected') return print('SAIDIN FILE = ',self.FILENAME.get()) self.destroy()
def _get(): # =========== out = tk.filedialog.askdirectory(parent=win,title='Target folder') #out = simple_form('Output folder for download files','path','./') if empty(out): out = None for i in range(len(FLIST)): bb = wget.download(FLIST[i],out=out)
def saidin_hour(self): name = self.filename(self.PATH) if not empty(name): self.FILENAME.set(name) self.preview() else: print('No image selected') self.FILENAME.set('')
def _get(): # =========== out = tk.filedialog.askdirectory(parent=win, title='Target folder') #out = simple_form('Output folder for download files','path','./') if empty(out): out = None for i in range(len(FLIST)): bb = wget.download(FLIST[i], out=out)
def saidin_hour(self): #==================== name = self.filename(self.PATH) if not empty(name): self.FILENAME.set(name) self.preview() else: toconsola('No image selected', wid=self.cons) #print('No image selected') self.FILENAME.set('')
def get_name(self): # -------------------------------------- if empty(self.LABEL_KEY.get()): print('No name selected') records = list(self.shp.records()) self.name = [] for i in range(len(records)): self.name.append(records[i].attributes[self.LABEL_KEY.get()])
def select_tfile(): if empty(CLM.TFILE.get()): CLM.TINDEX = None CLM.Tx.set('') CLM.Ty.set('') CLM.Tz.set('') CLM.Tt.set('') CLM.Tvname.set('') else: CLM.TINDEX = self.FLIST.index(CLM.TFILE.get()) CLM.Tx.set(CLM.VEC[CLM.TINDEX].icdf.xname) CLM.Ty.set(CLM.VEC[CLM.TINDEX].icdf.yname) CLM.Tz.set(CLM.VEC[CLM.TINDEX].icdf.zname) CLM.Tt.set(CLM.VEC[CLM.TINDEX].icdf.tname)
def select_tfile(): if empty(CLM.TFILE.get()): CLM.TINDEX = None CLM.Tx.set('') CLM.Ty.set('') CLM.Tz.set('') CLM.Tt.set('') CLM.Tvname.set('') else: CLM.TINDEX = self.ULIST.index(CLM.TFILE.get()) CLM.Tx.set(CLM.VEC[CLM.TINDEX].U.icdf.xname) CLM.Ty.set(CLM.VEC[CLM.TINDEX].U.icdf.yname) CLM.Tz.set(CLM.VEC[CLM.TINDEX].U.icdf.zname) CLM.Tt.set(CLM.VEC[CLM.TINDEX].U.icdf.tname)
def select_vfile(): if empty(CLM.VFILE.get()): CLM.VINDEX = None CLM.Vx.set('') CLM.Vy.set('') CLM.Vz.set('') CLM.Vt.set('') vid = CLM.VEC[CLM.UINDEX].vid CLM.Vv.set(CLM.VEC[CLM.UINDEX].icdf.vname[vid]) else: CLM.VINDEX = self.FLIST.index(CLM.VFILE.get()) vid = CLM.VEC[CLM.VINDEX].vid CLM.Vx.set(CLM.VEC[CLM.VINDEX].icdf.xname) CLM.Vy.set(CLM.VEC[CLM.VINDEX].icdf.yname) CLM.Vz.set(CLM.VEC[CLM.VINDEX].icdf.zname) CLM.Vt.set(CLM.VEC[CLM.VINDEX].icdf.tname) CLM.Vv.set(CLM.VEC[CLM.VINDEX].icdf.vname[vid])
def select_vfile(): if empty(CLM.VFILE.get()): CLM.VINDEX = None CLM.Vx.set('') CLM.Vy.set('') CLM.Vz.set('') CLM.Vt.set('') vid = CLM.VEC[CLM.VINDEX].V.varid CLM.Vv.set(CLM.VEC[CLM.VINDEX].V.icdf.vname[vid]) else: CLM.VINDEX = self.VLIST.index(CLM.VFILE.get()) vid = CLM.VEC[CLM.VINDEX].V.varid CLM.Vx.set(CLM.VEC[CLM.VINDEX].V.icdf.xname) CLM.Vy.set(CLM.VEC[CLM.VINDEX].V.icdf.yname) CLM.Vz.set(CLM.VEC[CLM.VINDEX].V.icdf.zname) CLM.Vt.set(CLM.VEC[CLM.VINDEX].V.icdf.tname) CLM.Vv.set(CLM.VEC[CLM.VINDEX].V.icdf.vname[vid])
def preview(self): #================= '''Preview map in window''' theurl = self.FILENAME.get() toconsola('TEST SHOW theurl >>' + theurl, wid=self.cons) #print('TEST SHOW theurl >>',theurl) if empty(theurl): messagebox.showinfo(message='No image selected') return self.ax1.clear() toconsola('Preview of ' + theurl, wid=self.cons) #print('Preview of ',theurl) icdf = Dataset(theurl, 'r') lon = icdf.variables['lon'][:] lat = icdf.variables['lat'][:] sst = icdf.variables['mcsst'][0, :, :].squeeze() icdf.close() xxT, yyT = np.meshgrid(lon, lat) SOUTH = np.min(lat) NORTH = np.max(lat) WEST = np.min(lon) EAST = np.max(lon) #print([EAST, WEST,SOUTH, NORTH]) #EG mod faltan los detalles line,fill self.ax1.set_extent([EAST, WEST, SOUTH, NORTH]) self.ax1.coastlines('110m', linewidth=2) #EG pcolormesh is faster #self.ax1.contourf(xxT,yyT,sst,transform=ccrs.PlateCarree()) self.ax1.pcolormesh(xxT, yyT, sst, transform=ccrs.PlateCarree()) #m = Basemap(llcrnrlat=SOUTH,urcrnrlat=NORTH, \ #llcrnrlon=WEST,urcrnrlon=EAST, \ #ax=self.ax1) #m.fillcontinents(color='coral') #m.drawcoastlines(linewidth=1) #m.contourf(xxT,yyT,sst) #EG self.canvas.draw() toconsola('done', wid=self.cons)
def filename(self,PATH): nmonth = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'] # Get the selected hour: value_selected = self.hourbox.get() if (empty(value_selected)): messagebox.showinfo(message='No image selected') theurl = '' return theurl else: for ind,name in enumerate(self.SEL): if name == value_selected: thesat = self.SAT[ind] year = self.YEAR.get() month = self.MONTH.get() day = self.DAY.get() hour = self.hour_var.get() theurl = PATH + str(year) + '/' + '%02d-' % month + \ nmonth[month-1]+ '/%02d/' % day + \ str(year) + '%02d' % month + '%02d' % day + \ '.' + hour[0:2]+hour[3:5] + '.' + thesat + '.nc' return theurl
def Basic_options(CLM): # ===================== options = ' -OU' + ' file=%s' % CLM.UFILE.get() \ + ' x=%s' % CLM.Ux.get() \ + ' y=%s' % CLM.Uy.get() if empty(CLM.Uz.get()): pass else: options += ' z=%s' % CLM.Uz.get() if empty(CLM.Ut.get()): pass else: options += ' t=%s' % CLM.Ut.get() options += ' var=%s' % CLM.Uu.get() options += ' -OV' if empty(CLM.VFILE.get()): pass else: options += ' file=%s' % CLM.VFILE.get() if empty(CLM.Vx.get()): pass else: options += ' x=%s' % CLM.Vx.get() if empty(CLM.Vy.get()): pass else: options += ' y=%s' % CLM.Vy.get() if empty(CLM.Vz.get()): pass else: options += ' z=%s' % CLM.Vz.get() if empty(CLM.Vt.get()): pass else: options += ' t=%s' % CLM.Vt.get() options += ' var=%s' % CLM.Vv.get() if empty(CLM.TRAJECTORY.get()): pass else: options += ' -trajectory %s' % CLM.TRAJECTORY.get() if empty(CLM.FIN.get()): pass else: options += ' -final %s' % CLM.FIN.get() if CLM.crop.get(): try: aa = ' -xmin %s' % CLM.west.get() options += aa except: pass try: aa = ' -xmax %s' % CLM.east.get() options += aa except: pass try: aa = ' -ymin %s' % CLM.south.get() options += aa except: pass try: aa = ' -ymax %s' % CLM.north.get() options += aa except: pass if empty(CLM.Dini.get()): pass else: d = '%s' % CLM.Dini.get() d = d.replace(' ', 'T') aa = ' -from %s' % d options += aa try: aa = ' -for %s' % CLM.Duration.get() options += aa except: pass if CLM.INI_USE.get(): if empty(CLM.INI.get()): messagebox.showinfo(message='No release file has been selected') return '' else: aa = ' -release %s' % CLM.INI.get() options += aa else: try: aa = ' -xo %s' % CLM.xo.get() options += aa except: messagebox.showinfo(message='Invalid release longitude') return '' try: aa = ' -yo %s' % CLM.yo.get() options += aa except: messagebox.showinfo(message='Invalid release latitude') return '' try: aa = ' -zo %s' % CLM.zo.get() options += aa except: messagebox.showinfo(message='Invalid release depth') return '' try: aa = ' -to %s' % CLM.to.get() options += aa except: messagebox.showinfo(message='Invalid release time') return '' try: aa = ' -dt %s' % CLM.dt.get() options += aa except: pass if CLM.reverse.get(): options += ' -reverse' try: aa = ' -alpha %s' % CLM.alpha.get() options += aa except: pass try: aa = ' -mu %s' % CLM.mu.get() options += aa except: pass try: aa = ' -va %s' % CLM.va.get() options += aa except: pass return options
def open_geojson(self, ask=True, filename=None): # --------------------------------------------- ''' Opening geojson file ''' if ask or filename is None: backup = self.Trajectory_name.get() try: nn = filedialog.askopenfile( filetypes=[('GEOJSON', '*.geojson'), ('JSON', '*.json'), ('ALL', '*.*')]) self.Trajectory_name.set(nn.name) except: self.Trajectory_name.set(backup) else: self.Trajectory_name.set(filename) if not empty(self.Trajectory_name.get()): # Read the GEOJSON file using json.load # ::::::::::::::::::::::::::::::::::::: with open(self.Trajectory_name.get()) as data_file: self.DATA = json.load(data_file) # Split the information into LON, LAT, SST, etc # ::::::::::::::::::::::::::::::::::::::::::::: self.Trajectory_read = True self.Nfeatures = len(self.DATA["features"]) for i in range(self.Nfeatures): if self.DATA["features"][i]["geometry"][ "type"] == "LineString": self.Trajectory_POINTS = self.DATA["features"][i][ "geometry"]["coordinates"] self.Trajectory_date = self.DATA["features"][i][ "properties"]["time"]["data"] try: self.Trajectory_temp = self.DATA["features"][i][ "properties"]["sst"]["data"] except: self.Trajectory_temp = [] self.Trajectory_length.set(len(self.Trajectory_date)) self.Trajectory_lon = [ self.Trajectory_POINTS[j][0] for j in range(self.Trajectory_length.get()) ] self.Trajectory_lat = [ self.Trajectory_POINTS[j][1] for j in range(self.Trajectory_length.get()) ] self.Trajectory_seconds = [] for i in range(self.Trajectory_length.get()): tt = dparser.parse(self.Trajectory_date[i]) self.Trajectory_seconds.append(int(tt.strftime('%s'))) # Get travelled distance (in meters) # :::::::::::::::::::::::::::::::::: self.Trajectory_reject = [] self.Trajectory_distance = [] for i in range(self.Trajectory_length.get()): self.Trajectory_reject.append(tk.IntVar()) self.Trajectory_reject[i].set(0) if i == 0: self.Trajectory_distance.append(float(0)) dist = 0 else: dr = haversine(self.Trajectory_POINTS[i], self.Trajectory_POINTS[i - 1]) dist += dr self.Trajectory_distance.append(dist) # Get time between stations self.Trajectory_time = [] for i in range(self.Trajectory_length.get()): if i == 0: self.Trajectory_time.append(float(0)) else: #now = iso8601.parse_date(self.Trajectory_date[i]) #pre = iso8601.parse_date(self.Trajectory_date[i-1]) now = datetime.datetime.strptime( self.Trajectory_date[i][0:18], '%Y-%m-%dT%H:%M:%S') pre = datetime.datetime.strptime( self.Trajectory_date[i - 1][0:18], '%Y-%m-%dT%H:%M:%S') secs = (now - pre).seconds self.Trajectory_time.append(secs) # Speed required to move between stations self.Trajectory_speed = [] self.Trajectory_speed.append(0) # AAA print(self.Trajectory_time) for i in range(1, self.Trajectory_length.get()): if self.Trajectory_time[i] < 1E-3: u = 0 else: u = (self.Trajectory_distance[i] - self.Trajectory_distance[i - 1]) / self.Trajectory_time[i] self.Trajectory_speed.append(u) self.map_size = 1.0 self.data_xmin = min(self.Trajectory_lon) self.data_xmax = max(self.Trajectory_lon) self.data_ymin = min(self.Trajectory_lat) self.data_ymax = max(self.Trajectory_lat) self.data_xsize = self.data_xmax - self.data_xmin self.data_ysize = self.data_ymax - self.data_ymin self.Mapxmin.set(myround(self.data_xmin - \ self.map_size*self.data_xsize,2)) self.Mapxmax.set(myround(self.data_xmax + \ self.map_size*self.data_xsize,2)) self.Mapymin.set(myround(self.data_ymin - \ self.map_size*self.data_ysize,2)) self.Mapymax.set(myround(self.data_ymax + \ self.map_size*self.data_ysize,2)) #self.Mapxmin.set(myround(self.data_xmin-0.5,1)) #self.Mapxmax.set(myround(self.data_xmax+0.5,1)) #self.Mapymin.set(myround(self.data_ymin-0.5,1)) #self.Mapymax.set(myround(self.data_ymax+0.5,1)) self.Station_pointer.set(0) self.Station_date.set(self.Trajectory_date[0]) self.Station_lon.set(self.Trajectory_lon[0]) self.Station_lat.set(self.Trajectory_lat[0]) self.Station_speed.set(self.Trajectory_speed[0]) self.Station_reject.set(self.Trajectory_reject[0].get()) self.Deploy_date.set(self.Trajectory_date[0]) self.Recover_date.set( self.Trajectory_date[self.Trajectory_length.get() - 1]) self.ax1.clear() self.draw_map() self.make_plot() # Scan for info about points: for i in range(self.Nfeatures): if self.DATA["features"][i]["geometry"]["type"] == "Point": #print(self.DATA["features"][i]["properties"]) if self.DATA["features"][i]["properties"]["event"] == 0: self.event0_lon.set(self.DATA["features"][i] ["geometry"]["coordinates"][0]) self.event0_lat.set(self.DATA["features"][i] ["geometry"]["coordinates"][1]) self.serial_number.set( self.DATA["features"][i]["properties"]["code_sn"]) self.buoy_name.set( self.DATA["features"][i]["properties"]["name"]) self.contact.set( self.DATA["features"][i]["properties"]["contact"]) self.source.set( self.DATA["features"][i]["properties"]["source"]) self.owner.set( self.DATA["features"][i]["properties"]["owner"]) self.event0_date.set(self.DATA["features"][i] ["properties"]["time"]["data"][0]) self.event0_qc.set(self.DATA["features"][i] ["properties"]["time"]["qc_data"]) try: a = self.event0_qc.get() except: self.event0_qc.set(0) #self.event0_qc.set(self.DATA["features"][i]["properties"]["qc"]) self.time_units.set(self.DATA["features"][i] ["properties"]["time"]["units"]) if self.DATA["features"][i]["properties"]["event"] == 1: self.event1_lon.set(self.DATA["features"][i] ["geometry"]["coordinates"][0]) self.event1_lat.set(self.DATA["features"][i] ["geometry"]["coordinates"][1]) self.event1_date.set(self.DATA["features"][i] ["properties"]["time"]["data"][0]) self.event1_qc.set(self.DATA["features"][i] ["properties"]["time"]["qc_data"]) try: a = self.event1_qc.get() except: self.event1_qc.set(0) #self.event1_qc.set(self.DATA["features"][i]["properties"]["qc"]) self.buoy_name_orig = self.buoy_name.get() self.source_orig = self.source.get() self.owner_orig = self.owner.get() self.contact_orig = self.contact.get() self.time_units_orig = self.time_units.get() self.event0_lon_orig = self.event0_lon.get() self.event0_lat_orig = self.event0_lat.get() self.event0_date_orig = self.event0_date.get() self.event0_qc_orig = self.event0_qc.get() self.event1_lon_orig = self.event1_lon.get() self.event1_lat_orig = self.event1_lat.get() self.event1_date_orig = self.event0_date.get() self.event1_qc_orig = self.event0_qc.get() else: self.DATA = None self.Trajectory = None self.Trajectory_read = False self.Nfeatures = 0
def Basic_options(CLM): # ===================== options = ' -U' + ' file=%s' % CLM.UFILE.get() \ + ' x=%s' % CLM.Ux.get() \ + ' y=%s' % CLM.Uy.get() if empty(CLM.Uz.get()): pass else: options += ' z=%s' % CLM.Uz.get() if empty(CLM.Ut.get()): pass else: options += ' t=%s' % CLM.Ut.get() options += ' u=%s' % CLM.Uu.get() options += ' -V' if empty(CLM.VFILE.get()): pass else: options += ' file=%s' % CLM.VFILE.get() if empty(CLM.Vx.get()): pass else: options += ' x=%s' % CLM.Vx.get() if empty(CLM.Vy.get()): pass else: options += ' y=%s' % CLM.Vy.get() if empty(CLM.Vz.get()): pass else: options += ' z=%s' % CLM.Vz.get() if empty(CLM.Vt.get()): pass else: options += ' t=%s' % CLM.Vt.get() options += ' v=%s' % CLM.Vv.get() if empty(CLM.TRAJECTORY.get()): pass else: options += ' -traj %s' % CLM.TRAJECTORY.get() if empty(CLM.FIN.get()): pass else: options += ' -end %s' % CLM.FIN.get() if CLM.INI_USE.get(): if empty(CLM.INI.get()): messagebox.showinfo(message='No release file has been selected') return '' else: aa = ' -release %s' % CLM.INI.get() options += aa else: try: aa = ' -xo %s' % CLM.xo.get() options += aa except: messagebox.showinfo(message='Invalid release longitude') return '' try: aa = ' -yo %s' % CLM.yo.get() options += aa except: messagebox.showinfo(message='Invalid release latitude') return '' try: aa = ' -idt %s' % CLM.idt.get() options += aa except: pass try: aa = ' -edt %s' % CLM.edt.get() options += aa except: pass return options
def Basic_options(CLM): # ===================== options = ' -U' + ' file=%s' % CLM.UFILE.get() \ + ' x=%s' % CLM.Ux.get() \ + ' y=%s' % CLM.Uy.get() if empty(CLM.Uz.get()): pass else: options += ' z=%s' % CLM.Uz.get() if empty(CLM.Ut.get()): pass else: options += ' t=%s' % CLM.Ut.get() options += ' u=%s' % CLM.Uu.get() options += ' -V' if empty(CLM.VFILE.get()): pass else: options += ' file=%s' % CLM.VFILE.get() if empty(CLM.Vx.get()): pass else: options += ' x=%s' % CLM.Vx.get() if empty(CLM.Vy.get()): pass else: options += ' y=%s' % CLM.Vy.get() if empty(CLM.Vz.get()): pass else: options += ' z=%s' % CLM.Vz.get() if empty(CLM.Vt.get()): pass else: options += ' t=%s' % CLM.Vt.get() options += ' v=%s' % CLM.Vv.get() if empty(CLM.TRAJECTORY.get()): pass else: options += ' -out %s' % CLM.TRAJECTORY.get() if empty(CLM.FIN.get()): pass else: options += ' -end %s' % CLM.FIN.get() if CLM.INI_USE.get(): if empty(CLM.INI.get()): messagebox.showinfo(message='No release file has been selected') return '' else: aa = ' -release %s' % CLM.INI.get() options += aa else: try: aa = ' -x0 %s' % CLM.xo.get() options += aa except: messagebox.showinfo(message='Invalid release longitude') return '' try: aa = ' -y0 %s' % CLM.yo.get() options += aa except: messagebox.showinfo(message='Invalid release latitude') return '' #try: # aa = ' -idt %s' % CLM.idt.get() # options += aa #except: # pass try: aa = ' -edt %s' % CLM.edt.get() options += aa except: pass return options
def open_geojson(self,ask=True,filename=None): # --------------------------------------------- ''' Opening geojson file ''' if ask or filename is None: backup = self.Trajectory_name.get() try: nn = filedialog.askopenfile(filetypes=[('GEOJSON','*.geojson'),('JSON','*.json'),('ALL','*.*')]) self.Trajectory_name.set(nn.name) except: self.Trajectory_name.set(backup) else: self.Trajectory_name.set(filename) if not empty(self.Trajectory_name.get()): # Read the GEOJSON file using json.load # ::::::::::::::::::::::::::::::::::::: with open(self.Trajectory_name.get()) as data_file: self.DATA = json.load(data_file) # Split the information into LON, LAT, SST, etc # ::::::::::::::::::::::::::::::::::::::::::::: self.Trajectory_read = True self.Nfeatures = len(self.DATA["features"]) for i in range(self.Nfeatures): if self.DATA["features"][i]["geometry"]["type"] == "LineString": self.Trajectory_POINTS = self.DATA["features"][i]["geometry"]["coordinates"] self.Trajectory_date = self.DATA["features"][i]["properties"]["time"]["data"] try: self.Trajectory_temp = self.DATA["features"][i]["properties"]["sst"]["data"] except: self.Trajectory_temp = [] self.Trajectory_length.set(len(self.Trajectory_date)) self.Trajectory_lon = [self.Trajectory_POINTS[j][0] for j in range(self.Trajectory_length.get())] self.Trajectory_lat = [self.Trajectory_POINTS[j][1] for j in range(self.Trajectory_length.get())] self.Trajectory_seconds = [] for i in range(self.Trajectory_length.get()): tt = dparser.parse(self.Trajectory_date[i]) self.Trajectory_seconds.append(int(tt.strftime('%s'))) # Get travelled distance (in meters) # :::::::::::::::::::::::::::::::::: self.Trajectory_reject = [] self.Trajectory_distance = [] for i in range(self.Trajectory_length.get()): self.Trajectory_reject.append(tk.IntVar()) self.Trajectory_reject[i].set(0) if i == 0: self.Trajectory_distance.append(float(0)) dist = 0 else: dr = haversine(self.Trajectory_POINTS[i],self.Trajectory_POINTS[i-1]) dist += dr self.Trajectory_distance.append(dist) # Get time between stations self.Trajectory_time = [] for i in range(self.Trajectory_length.get()): if i == 0: self.Trajectory_time.append(float(0)) else: #now = iso8601.parse_date(self.Trajectory_date[i]) #pre = iso8601.parse_date(self.Trajectory_date[i-1]) now = datetime.datetime.strptime(self.Trajectory_date[i][0:18],'%Y-%m-%dT%H:%M:%S') pre = datetime.datetime.strptime(self.Trajectory_date[i-1][0:18],'%Y-%m-%dT%H:%M:%S') secs = (now-pre).seconds self.Trajectory_time.append(secs) # Speed required to move between stations self.Trajectory_speed = [] self.Trajectory_speed.append(0) # AAA print(self.Trajectory_time) for i in range(1,self.Trajectory_length.get()): if self.Trajectory_time[i] < 1E-3: u = 0 else: u = (self.Trajectory_distance[i]- self.Trajectory_distance[i-1])/self.Trajectory_time[i] self.Trajectory_speed.append(u) self.map_size = 1.0 self.data_xmin = min(self.Trajectory_lon) self.data_xmax = max(self.Trajectory_lon) self.data_ymin = min(self.Trajectory_lat) self.data_ymax = max(self.Trajectory_lat) self.data_xsize = self.data_xmax - self.data_xmin self.data_ysize = self.data_ymax - self.data_ymin self.Mapxmin.set(myround(self.data_xmin - \ self.map_size*self.data_xsize,2)) self.Mapxmax.set(myround(self.data_xmax + \ self.map_size*self.data_xsize,2)) self.Mapymin.set(myround(self.data_ymin - \ self.map_size*self.data_ysize,2)) self.Mapymax.set(myround(self.data_ymax + \ self.map_size*self.data_ysize,2)) #self.Mapxmin.set(myround(self.data_xmin-0.5,1)) #self.Mapxmax.set(myround(self.data_xmax+0.5,1)) #self.Mapymin.set(myround(self.data_ymin-0.5,1)) #self.Mapymax.set(myround(self.data_ymax+0.5,1)) self.Station_pointer.set(0) self.Station_date.set(self.Trajectory_date[0]) self.Station_lon.set(self.Trajectory_lon[0]) self.Station_lat.set(self.Trajectory_lat[0]) self.Station_speed.set(self.Trajectory_speed[0]) self.Station_reject.set(self.Trajectory_reject[0].get()) self.Deploy_date.set(self.Trajectory_date[0]) self.Recover_date.set(self.Trajectory_date[self.Trajectory_length.get()-1]) self.ax1.clear() self.draw_map() self.make_plot() # Scan for info about points: for i in range(self.Nfeatures): if self.DATA["features"][i]["geometry"]["type"] == "Point": #print(self.DATA["features"][i]["properties"]) if self.DATA["features"][i]["properties"]["event"] == 0: self.event0_lon.set(self.DATA["features"][i]["geometry"]["coordinates"][0]) self.event0_lat.set(self.DATA["features"][i]["geometry"]["coordinates"][1]) self.serial_number.set(self.DATA["features"][i]["properties"]["code_sn"]) self.buoy_name.set(self.DATA["features"][i]["properties"]["name"]) self.contact.set(self.DATA["features"][i]["properties"]["contact"]) self.source.set(self.DATA["features"][i]["properties"]["source"]) self.owner.set(self.DATA["features"][i]["properties"]["owner"]) self.event0_date.set(self.DATA["features"][i]["properties"]["time"]["data"][0]) self.event0_qc.set(self.DATA["features"][i]["properties"]["time"]["qc_data"]) try: a = self.event0_qc.get() except: self.event0_qc.set(0) #self.event0_qc.set(self.DATA["features"][i]["properties"]["qc"]) self.time_units.set(self.DATA["features"][i]["properties"]["time"]["units"]) if self.DATA["features"][i]["properties"]["event"] == 1: self.event1_lon.set(self.DATA["features"][i]["geometry"]["coordinates"][0]) self.event1_lat.set(self.DATA["features"][i]["geometry"]["coordinates"][1]) self.event1_date.set(self.DATA["features"][i]["properties"]["time"]["data"][0]) self.event1_qc.set(self.DATA["features"][i]["properties"]["time"]["qc_data"]) try: a = self.event1_qc.get() except: self.event1_qc.set(0) #self.event1_qc.set(self.DATA["features"][i]["properties"]["qc"]) self.buoy_name_orig = self.buoy_name.get() self.source_orig = self.source.get() self.owner_orig = self.owner.get() self.contact_orig = self.contact.get() self.time_units_orig = self.time_units.get() self.event0_lon_orig = self.event0_lon.get() self.event0_lat_orig = self.event0_lat.get() self.event0_date_orig = self.event0_date.get() self.event0_qc_orig = self.event0_qc.get() self.event1_lon_orig = self.event1_lon.get() self.event1_lat_orig = self.event1_lat.get() self.event1_date_orig = self.event0_date.get() self.event1_qc_orig = self.event0_qc.get() else: self.DATA = None self.Trajectory = None self.Trajectory_read = False self.Nfeatures = 0