#remove bad inds obs_time = np.delete(obs_time,bad_inds) all_var = np.delete(all_var,bad_inds) #put data into big array all_data = np.empty((len(all_var),47)) all_data[:,:] = -99999 for i,l in zip(range(len(all_var)),level_inds): all_data[i,l] = all_var[i] country = '' while country == '': try: country = modules.get_country(np.float64(current_lat),np.float64(current_lon)) except: pass # dimensions root_grp.createDimension('time%s'%(site_count), len(obs_time)) root_grp.createDimension('species%s'%(site_count), len(all_var)) root_grp.createDimension('press%s'%(site_count), 47) #save out netcdf file ref = root_grp.createGroup('%s'%(site_name.lower())) #set variables times = ref.createVariable('time', 'f8', ('time%s'%(site_count),)) spec = ref.createVariable(species.lower(), 'f4', ('species%s'%(site_count),'press%s'%(site_count))) p_c = ref.createVariable('pressure_centres', 'f4', ('press%s'%(site_count),))
#check timezone #if timezone != 'UTC': # print 'Timezone is not UTC. Is %s'%(timezone) # fail = 1+'a' #Remove sites above 1000m from sea level if np.float64(altitude) >= 1000: full_exit = True print 'Site is over 1000m from sea level.' if full_exit == False: print 'Site is Valid' country = '' while country == '': try: country = modules.get_country(np.float64(latitude),np.float64(longitude)) except: pass #save out netcdf file ref = root_grp.createGroup('%s'%(site_ref.lower())) #set variables dates = ref.createVariable('date', 'i8', ('date',)) times = ref.createVariable('time', 'i8', ('time',)) spec = ref.createVariable(species.lower(), 'f8', ('species',)) #set group attributes ref.latitude = np.float64(latitude) ref.longitude = np.float64(longitude)
#check timezone #if timezone != 'UTC': # print 'Timezone is not UTC. Is %s'%(timezone) # fail = 1+'a' #Remove sites above 1000m from sea level if np.float64(altitude) >= 1000: full_exit = True print 'Site is over 1000m from sea level.' if full_exit == False: print 'Site is Valid' country = '' while country == '': try: country = modules.get_country(np.float64(latitude), np.float64(longitude)) except: pass #save out netcdf file ref = root_grp.createGroup('%s' % (site_ref.lower())) #set variables dates = ref.createVariable('date', 'i8', ('date', )) times = ref.createVariable('time', 'i8', ('time', )) spec = ref.createVariable(species.lower(), 'f8', ('species', )) #set group attributes ref.latitude = np.float64(latitude) ref.longitude = np.float64(longitude) ref.altitude = np.float64(altitude)
all_var = np.delete(all_var,bad_inds) #calc gregorian time dt_times = date2num(datetimes, units='hours since 0001-01-01 00:00:00', calendar='gregorian') #put data into big array all_data = np.empty((len(all_var),47)) all_data[:,:] = -99999 for i,l in zip(range(len(all_var)),level_inds): all_data[i,l] = all_var[i] country = '' while country == '': try: country = modules.get_country(np.float64(lat),np.float64(lon)) except: pass # dimensions root_grp.createDimension('time%s'%(site_count), len(obs_time)) root_grp.createDimension('species%s'%(site_count), len(all_var)) root_grp.createDimension('press%s'%(site_count), 47) #save out netcdf file ref = root_grp.createGroup('%s'%(site.lower())) #set variables times = ref.createVariable('time', 'f8', ('time%s'%(site_count),)) spec = ref.createVariable(species.lower(), 'f4', ('species%s'%(site_count),'press%s'%(site_count))) p_c = ref.createVariable('pressure_centres', 'f4', ('press%s'%(site_count),))
#calc gregorian time dt_times = date2num(datetimes, units='hours since 0001-01-01 00:00:00', calendar='gregorian') #put data into big array all_data = np.empty((len(all_var), 47)) all_data[:, :] = -99999 for i, l in zip(range(len(all_var)), level_inds): all_data[i, l] = all_var[i] country = '' while country == '': try: country = modules.get_country(np.float64(lat), np.float64(lon)) except: pass # dimensions root_grp.createDimension('time%s' % (site_count), len(obs_time)) root_grp.createDimension('species%s' % (site_count), len(all_var)) root_grp.createDimension('press%s' % (site_count), 47) #save out netcdf file ref = root_grp.createGroup('%s' % (site.lower())) #set variables times = ref.createVariable('time', 'f8', ('time%s' % (site_count), )) spec = ref.createVariable(species.lower(), 'f4',