def Storm_Tide_Water_Level(self, so): out_fname2 = ''.join([so.output_fname, '_stormtide', '.nc']) step = 4 nc.custom_copy(so.sea_fname, out_fname2, so.begin, so.end, mode='storm_surge', step=step) self.Common_Attributes(so, out_fname2, step) nc.set_global_attribute( out_fname2, 'summary', 'This file contains two time series: 1)' 'air pressure 2) sea surface elevation. The latter was derived' ' from a time series of high frequency sea pressure measurements ' ' adjusted using the former and then lowpass filtered to remove ' ' waves of period 1 second or less.') nc.append_depth(out_fname2, so.surge_water_level[::step]) sea_uuid = nc.get_global_attribute(so.sea_fname, 'uuid') air_uuid = nc.get_global_attribute(so.air_fname, 'uuid') nc.set_var_attribute(out_fname2, 'air_pressure', 'air_uuid', air_uuid) nc.set_var_attribute(out_fname2, 'water_surface_height_above_reference_datum', \ 'air_uuid', air_uuid) nc.set_var_attribute(out_fname2, 'water_surface_height_above_reference_datum', \ 'sea_uuid', sea_uuid)
def Common_Attributes(self,so,file_name,step): #nc.set_var_attribute(water_fname, 'sea_pressure', 'sea_uuid', sea_uuid) nc.set_global_attribute(file_name, 'uuid', str(uuid.uuid4())) #append air pressure instr_dict = nc.get_instrument_data(so.air_fname, 'air_pressure') nc.append_air_pressure(file_name, so.interpolated_air_pressure[::step], so.air_fname) nc.set_instrument_data(file_name, 'air_pressure', instr_dict) #update the lat and lon comments lat_comment = nc.get_variable_attr(file_name, 'latitude', 'comment') nc.set_var_attribute(file_name, 'latitude', 'comment', \ ''.join([lat_comment, ' Latitude of sea pressure sensor used to derive ' \ 'sea surface elevation.'])) lon_comment = nc.get_variable_attr(file_name, 'longitude', 'comment') nc.set_var_attribute(file_name, 'longitude', 'comment', \ ''.join([lon_comment, ' Longitude of sea pressure sensor used to derive ' \ 'sea surface elevation.'])) #set sea_pressure instrument data to global variables in water_level netCDF sea_instr_data = nc.get_instrument_data(so.sea_fname,'sea_pressure') for x in sea_instr_data: attrname = ''.join(['sea_pressure_',x]) nc.set_global_attribute(file_name,attrname,sea_instr_data[x]) lat = nc.get_variable_data(file_name, 'latitude') lon = nc.get_variable_data(file_name, 'longitude') first_stamp = nc.get_global_attribute(file_name, 'time_coverage_start') last_stamp = nc.get_global_attribute(file_name, 'time_coverage_end') nc.set_global_attribute(file_name,'title','Calculation of water level at %.4f latitude,' ' %.4f degrees longitude from the date range of %s to %s.' % (lat,lon,first_stamp,last_stamp))
def get_meta_data(self): if self.datum is None: self.datum = nc.get_geospatial_vertical_reference(self.sea_fname) self.latitude = nc.get_variable_data(self.sea_fname,'latitude') self.longitude = nc.get_variable_data(self.sea_fname,'longitude') self.stn_station_number = nc.get_global_attribute(self.sea_fname, 'stn_station_number') self.stn_instrument_id = nc.get_global_attribute(self.sea_fname, 'stn_instrument_id')
def get_meta_data(self): if self.datum is None: self.datum = nc.get_geospatial_vertical_reference(self.sea_fname) self.latitude = nc.get_variable_data(self.sea_fname, 'latitude') self.longitude = nc.get_variable_data(self.sea_fname, 'longitude') self.stn_station_number = nc.get_global_attribute( self.sea_fname, 'stn_station_number') self.stn_instrument_id = nc.get_global_attribute( self.sea_fname, 'stn_instrument_id')
def Wave_Statistics(self,so): out_fname2 = ''.join([so.output_fname,'_stormtide_unfiltered','.nc']) step = 1 nc.custom_copy(so.sea_fname, out_fname2, so.begin, so.end, mode = 'storm_surge', step=step) self.Common_Attributes(so, out_fname2, step) sea_uuid = nc.get_global_attribute(so.sea_fname, 'uuid') air_uuid = nc.get_global_attribute(so.air_fname, 'uuid') nc.wave_copy(so.sea_fname, out_fname2, so.begin, so.end, step = step, )
def get_air_meta_data(self): if self.air_latitude is None: if self.from_water_level_file == False: self.air_latitude = nc.get_variable_data(self.air_fname,'latitude') self.air_longitude = nc.get_variable_data(self.air_fname,'longitude') self.air_stn_station_number = nc.get_global_attribute(self.air_fname, 'stn_station_number') self.air_stn_instrument_id = nc.get_global_attribute(self.air_fname, 'stn_instrument_id') else: self.air_latitude = nc.get_variable_data(self.air_fname,'latitude') self.air_longitude = nc.get_variable_data(self.air_fname,'longitude') self.air_stn_station_number = nc.get_global_attribute(self.air_fname, 'stn_station_number') self.air_stn_instrument_id = nc.get_variable_attr(self.air_fname, 'air_pressure', 'instrument_serial_number')
def Storm_Tide_and_Unfiltered_Water_Level(self, so): out_fname2 = ''.join([so.output_fname, '_stormtide_unfiltered', '.nc']) step = 1 nc.custom_copy(so.sea_fname, out_fname2, so.begin, so.end, mode='storm_surge', step=step) self.Common_Attributes(so, out_fname2, step) nc.set_global_attribute( out_fname2, 'summary', 'This file contains three time series: 1)' ' air pressure 2) sea surface elevation 3) unfiltered sea surface elevation.' ' The second was derived' ' from a time series of high frequency sea pressure measurements' ' adjusted using the former and then lowpass filtered to remove' ' waves of period 1 second or less. The third is also sea surface elevation' ' with no such filter.') nc.append_depth(out_fname2, so.surge_water_level[::step]) sea_uuid = nc.get_global_attribute(so.sea_fname, 'uuid') air_uuid = nc.get_global_attribute(so.air_fname, 'uuid') nc.set_var_attribute(out_fname2, 'air_pressure', 'air_uuid', air_uuid) nc.append_variable(out_fname2, 'unfiltered_water_surface_height_above_reference_datum', so.raw_water_level[::step], \ 'Unfiltered Sea Surface Elevation', 'unfiltered_water_surface_height_above_reference_datum') nc.append_variable(out_fname2, 'wave_wl', so.wave_water_level[::step], \ 'wave_wl', 'wave_wl') nc.set_var_attribute(out_fname2, 'water_surface_height_above_reference_datum', \ 'air_uuid', air_uuid) nc.set_var_attribute(out_fname2, 'water_surface_height_above_reference_datum', \ 'sea_uuid', sea_uuid) nc.set_var_attribute(out_fname2, 'unfiltered_water_surface_height_above_reference_datum', \ 'air_uuid', air_uuid) nc.set_var_attribute(out_fname2, 'unfiltered_water_surface_height_above_reference_datum', \ 'sea_uuid', sea_uuid) nc.set_var_attribute(out_fname2, 'unfiltered_water_surface_height_above_reference_datum', \ 'units', 'meters') nc.set_var_attribute(out_fname2, 'unfiltered_water_surface_height_above_reference_datum', \ 'nodc_name', 'WATER LEVEL') nc.set_var_attribute(out_fname2, 'unfiltered_water_surface_height_above_reference_datum', \ 'ioos_category', 'sea_level')
def extract_salinity(self, fname): salinity = nc.get_global_attribute(fname, 'salinity') if salinity == "Salt Water (> 30 ppt)": return "salt" if salinity == "Brackish Water (.5 - 30 ppt)": return "brackish" return "fresh"
def get_wind_meta_data(self): if self.wind_latitude is None: try: self.wind_latitude = nc.get_variable_data(self.wind_fname,'latitude') self.wind_longitude = nc.get_variable_data(self.wind_fname,'longitude') self.wind_stn_station_number = nc.get_global_attribute(self.wind_fname, 'stn_station_number') except: self.wind_latitude = 0 self.wind_longitude = 0 self.wind_stn_station_number = 'na'
def get_air_meta_data(self): if self.air_latitude is None: if self.from_water_level_file == False: self.air_latitude = nc.get_variable_data( self.air_fname, 'latitude') self.air_longitude = nc.get_variable_data( self.air_fname, 'longitude') self.air_stn_station_number = nc.get_global_attribute( self.air_fname, 'stn_station_number') self.air_stn_instrument_id = nc.get_global_attribute( self.air_fname, 'stn_instrument_id') else: self.air_latitude = nc.get_variable_data( self.air_fname, 'latitude') self.air_longitude = nc.get_variable_data( self.air_fname, 'longitude') self.air_stn_station_number = nc.get_global_attribute( self.air_fname, 'stn_station_number') self.air_stn_instrument_id = nc.get_variable_attr( self.air_fname, 'air_pressure', 'instrument_serial_number')
def Storm_Tide_and_Unfiltered_Water_Level(self,so): out_fname2 = ''.join([so.output_fname,'_stormtide_unfiltered','.nc']) step = 1 nc.custom_copy(so.sea_fname, out_fname2, so.begin, so.end, mode = 'storm_surge', step=step) self.Common_Attributes(so, out_fname2, step) nc.set_global_attribute(out_fname2,'summary','This file contains three time series: 1)' ' air pressure 2) sea surface elevation 3) unfiltered sea surface elevation.' ' The second was derived' ' from a time series of high frequency sea pressure measurements' ' adjusted using the former and then lowpass filtered to remove' ' waves of period 1 second or less. The third is also sea surface elevation' ' with no such filter.') nc.append_depth(out_fname2, so.surge_water_level[::step]) sea_uuid = nc.get_global_attribute(so.sea_fname, 'uuid') air_uuid = nc.get_global_attribute(so.air_fname, 'uuid') nc.set_var_attribute(out_fname2, 'air_pressure', 'air_uuid', air_uuid) nc.append_variable(out_fname2, 'unfiltered_water_surface_height_above_reference_datum', so.raw_water_level[::step], \ 'Unfiltered Sea Surface Elevation', 'unfiltered_water_surface_height_above_reference_datum') nc.append_variable(out_fname2, 'wave_wl', so.wave_water_level[::step], \ 'wave_wl', 'wave_wl') nc.set_var_attribute(out_fname2, 'water_surface_height_above_reference_datum', \ 'air_uuid', air_uuid) nc.set_var_attribute(out_fname2, 'water_surface_height_above_reference_datum', \ 'sea_uuid', sea_uuid) nc.set_var_attribute(out_fname2, 'unfiltered_water_surface_height_above_reference_datum', \ 'air_uuid', air_uuid) nc.set_var_attribute(out_fname2, 'unfiltered_water_surface_height_above_reference_datum', \ 'sea_uuid', sea_uuid) nc.set_var_attribute(out_fname2, 'unfiltered_water_surface_height_above_reference_datum', \ 'units', 'meters') nc.set_var_attribute(out_fname2, 'unfiltered_water_surface_height_above_reference_datum', \ 'nodc_name', 'WATER LEVEL') nc.set_var_attribute(out_fname2, 'unfiltered_water_surface_height_above_reference_datum', \ 'ioos_category', 'sea_level')
def Wave_Statistics(self, so): out_fname2 = ''.join([so.output_fname, '_stormtide_unfiltered', '.nc']) step = 1 nc.custom_copy(so.sea_fname, out_fname2, so.begin, so.end, mode='storm_surge', step=step) self.Common_Attributes(so, out_fname2, step) sea_uuid = nc.get_global_attribute(so.sea_fname, 'uuid') air_uuid = nc.get_global_attribute(so.air_fname, 'uuid') nc.wave_copy( so.sea_fname, out_fname2, so.begin, so.end, step=step, )
def get_wind_meta_data(self): if self.wind_latitude is None: try: self.wind_latitude = nc.get_variable_data( self.wind_fname, 'latitude') self.wind_longitude = nc.get_variable_data( self.wind_fname, 'longitude') self.wind_stn_station_number = nc.get_global_attribute( self.wind_fname, 'stn_station_number') except: self.wind_latitude = 0 self.wind_longitude = 0 self.wind_stn_station_number = 'na'
def Storm_Tide_Water_Level(self, so): out_fname2 = ''.join([so.output_fname,'_stormtide','.nc']) step = 4 nc.custom_copy(so.sea_fname, out_fname2, so.begin, so.end, mode = 'storm_surge', step=step) self.Common_Attributes(so,out_fname2,step) nc.set_global_attribute(out_fname2,'summary','This file contains two time series: 1)' 'air pressure 2) sea surface elevation. The latter was derived' ' from a time series of high frequency sea pressure measurements ' ' adjusted using the former and then lowpass filtered to remove ' ' waves of period 1 second or less.') nc.append_depth(out_fname2, so.surge_water_level[::step]) sea_uuid = nc.get_global_attribute(so.sea_fname, 'uuid') air_uuid = nc.get_global_attribute(so.air_fname, 'uuid') nc.set_var_attribute(out_fname2, 'air_pressure', 'air_uuid', air_uuid) nc.set_var_attribute(out_fname2, 'water_surface_height_above_reference_datum', \ 'air_uuid', air_uuid) nc.set_var_attribute(out_fname2, 'water_surface_height_above_reference_datum', \ 'sea_uuid', sea_uuid)
def Common_Attributes(self, so, file_name, step): #nc.set_var_attribute(water_fname, 'sea_pressure', 'sea_uuid', sea_uuid) nc.set_global_attribute(file_name, 'uuid', str(uuid.uuid4())) #append air pressure instr_dict = nc.get_instrument_data(so.air_fname, 'air_pressure') nc.append_air_pressure(file_name, so.interpolated_air_pressure[::step], so.air_fname) nc.set_instrument_data(file_name, 'air_pressure', instr_dict) #update the lat and lon comments lat_comment = nc.get_variable_attr(file_name, 'latitude', 'comment') nc.set_var_attribute(file_name, 'latitude', 'comment', \ ''.join([lat_comment, ' Latitude of sea pressure sensor used to derive ' \ 'sea surface elevation.'])) lon_comment = nc.get_variable_attr(file_name, 'longitude', 'comment') nc.set_var_attribute(file_name, 'longitude', 'comment', \ ''.join([lon_comment, ' Longitude of sea pressure sensor used to derive ' \ 'sea surface elevation.'])) #set sea_pressure instrument data to global variables in water_level netCDF sea_instr_data = nc.get_instrument_data(so.sea_fname, 'sea_pressure') for x in sea_instr_data: attrname = ''.join(['sea_pressure_', x]) nc.set_global_attribute(file_name, attrname, sea_instr_data[x]) lat = nc.get_variable_data(file_name, 'latitude') lon = nc.get_variable_data(file_name, 'longitude') first_stamp = nc.get_global_attribute(file_name, 'time_coverage_start') last_stamp = nc.get_global_attribute(file_name, 'time_coverage_end') nc.set_global_attribute( file_name, 'title', 'Calculation of water level at %.4f latitude,' ' %.4f degrees longitude from the date range of %s to %s.' % (lat, lon, first_stamp, last_stamp))
def multi_water_level(self, path, title, mode='Raw'): self.create_header() ax = self.figure.add_subplot(self.grid_spec[1, 0:]) pos1 = ax.get_position() # get the original position pos2 = [pos1.x0, pos1.y0, pos1.width, pos1.height + .06] ax.set_position(pos2) # set a new position #create the second graph title first_title = "%s %s Water Level Time Series Comparison" % (title, mode) titleText = ax.text(0.5, 1.065,first_title, \ va='center', ha='center', transform=ax.transAxes) ax.set_ylabel('Water Level in Feet') ax.set_xlabel('Timezone GMT') #plot major grid lines ax.grid(b=True, which='major', color='grey', linestyle="-") #x axis formatter for dates (function format_date() below) ax.xaxis.set_major_formatter(ticker.FuncFormatter(self.format_date)) legend_list, label_list = [], [] air, sea, sea_file, air_file = False, False, '', '' file_types = ['.nc'] for root, sub_folders, files in os.walk(path): for file_in_root in files: index = file_in_root.rfind('.') if file_in_root[index:] in file_types: file = ''.join([root, '\\', file_in_root]) try: nc.get_pressure(file) sea = True sea_file = file except: try: nc.get_air_pressure(file) air = True air_file = file except: pass if sea and air: sea, air = False, False so = StormOptions() so.air_fname = air_file so.sea_fname = sea_file so.timezone = 'GMT' so.daylight_savings = False so.get_meta_data() so.get_air_meta_data() so.get_raw_water_level() so.get_surge_water_level() so.test_water_elevation_below_sensor_orifice_elvation() so.get_wave_water_level() first_date = unit_conversion.convert_ms_to_date( so.sea_time[0], pytz.UTC) last_date = unit_conversion.convert_ms_to_date( so.sea_time[-1], pytz.UTC) first_date = mdates.date2num(first_date) last_date = mdates.date2num(last_date) self.time_nums = np.linspace(first_date, last_date, len(so.sea_time)) lat = nc.get_variable_data(sea_file, 'latitude') lon = nc.get_variable_data(sea_file, 'longitude') stn_id = nc.get_global_attribute( sea_file, 'stn_instrument_id') stn_station = nc.get_global_attribute( sea_file, 'stn_station_number') if mode == 'Surge': p1, = ax.plot(self.time_nums, so.surge_water_level, alpha=.5) legend_list.append(p1) label_list.append('STN Site ID: %s, STN Instrument ID: %s, Lat: %s, Lon: %s' \ %(stn_id, stn_station, lat, lon)) if mode == 'Wave': p1, = ax.plot(self.time_nums, so.wave_water_level, alpha=.5) legend_list.append(p1) label_list.append('STN Site ID: %s, STN Instrument ID: %s, Lat: %s, Lon: %s' \ %(stn_id, stn_station, lat, lon)) if mode == 'Raw': p1, = ax.plot(self.time_nums, so.raw_water_level, alpha=.5) legend_list.append(p1) label_list.append('STN Site ID: %s, STN Instrument ID: %s, Lat: %s, Lon: %s' \ %(stn_id, stn_station, lat, lon)) legend = ax.legend(legend_list,label_list , \ bbox_to_anchor=(.95, 1.355), loc=1, borderaxespad=0.0, prop={'size':10.3},frameon=False,numpoints=1, \ title="EXPLANATION") legend.get_title().set_position((-340, 0)) plt.savefig(''.join([title, mode]))
def multi_air_pressure(self,path, title): self.create_header() ax = self.figure.add_subplot(self.grid_spec[1,0:]) pos1 = ax.get_position() # get the original position pos2 = [pos1.x0, pos1.y0, pos1.width, pos1.height + .06] ax.set_position(pos2) # set a new position #create the second graph title first_title = "%s Air Pressure Time Series Comparison" % title titleText = ax.text(0.5, 1.065,first_title, \ va='center', ha='center', transform=ax.transAxes) ax.set_ylabel('Air Pressure in Inches of Mercury') ax.set_xlabel('Timezone GMT') #plot major grid lines ax.grid(b=True, which='major', color='grey', linestyle="-") #x axis formatter for dates (function format_date() below) ax.xaxis.set_major_formatter(ticker.FuncFormatter(self.format_date)) legend_list, label_list = [], [] file_types = ['.nc'] for root, sub_folders, files in os.walk(path): for file_in_root in files: index = file_in_root.rfind('.') if file_in_root[index:] in file_types: file = ''.join([root,'\\',file_in_root]) try: air_pressure = nc.get_air_pressure(file) * unit_conversion.DBAR_TO_INCHES_OF_MERCURY time = nc.get_time(file) first_date = unit_conversion.convert_ms_to_date(time[0], pytz.UTC) last_date = unit_conversion.convert_ms_to_date(time[-1], pytz.UTC) first_date = mdates.date2num(first_date) last_date = mdates.date2num(last_date) self.time_nums = np.linspace(first_date, last_date, len(time)) lat = nc.get_variable_data(file, 'latitude') lon = nc.get_variable_data(file, 'longitude') stn_id = nc.get_global_attribute(file, 'stn_instrument_id') stn_station = nc.get_global_attribute(file, 'stn_station_number') p1, = ax.plot(self.time_nums, air_pressure, alpha=.5) legend_list.append(p1) label_list.append('STN Site ID: %s, STN Instrument ID: %s, Lat: %s, Lon: %s' \ %(stn_id, stn_station, lat, lon)) except: pass legend = ax.legend(legend_list,label_list , \ bbox_to_anchor=(.95, 1.355), loc=1, borderaxespad=0.0, prop={'size':10.3},frameon=False,numpoints=1, \ title="EXPLANATION") legend.get_title().set_position((-340, 0)) plt.savefig('b')
def multi_air_pressure(self, path, title): self.create_header() ax = self.figure.add_subplot(self.grid_spec[1, 0:]) pos1 = ax.get_position() # get the original position pos2 = [pos1.x0, pos1.y0, pos1.width, pos1.height + .06] ax.set_position(pos2) # set a new position #create the second graph title first_title = "%s Air Pressure Time Series Comparison" % title titleText = ax.text(0.5, 1.065,first_title, \ va='center', ha='center', transform=ax.transAxes) ax.set_ylabel('Air Pressure in Inches of Mercury') ax.set_xlabel('Timezone GMT') #plot major grid lines ax.grid(b=True, which='major', color='grey', linestyle="-") #x axis formatter for dates (function format_date() below) ax.xaxis.set_major_formatter(ticker.FuncFormatter(self.format_date)) legend_list, label_list = [], [] file_types = ['.nc'] for root, sub_folders, files in os.walk(path): for file_in_root in files: index = file_in_root.rfind('.') if file_in_root[index:] in file_types: file = ''.join([root, '\\', file_in_root]) try: air_pressure = nc.get_air_pressure( file) * unit_conversion.DBAR_TO_INCHES_OF_MERCURY time = nc.get_time(file) first_date = unit_conversion.convert_ms_to_date( time[0], pytz.UTC) last_date = unit_conversion.convert_ms_to_date( time[-1], pytz.UTC) first_date = mdates.date2num(first_date) last_date = mdates.date2num(last_date) self.time_nums = np.linspace(first_date, last_date, len(time)) lat = nc.get_variable_data(file, 'latitude') lon = nc.get_variable_data(file, 'longitude') stn_id = nc.get_global_attribute( file, 'stn_instrument_id') stn_station = nc.get_global_attribute( file, 'stn_station_number') p1, = ax.plot(self.time_nums, air_pressure, alpha=.5) legend_list.append(p1) label_list.append('STN Site ID: %s, STN Instrument ID: %s, Lat: %s, Lon: %s' \ %(stn_id, stn_station, lat, lon)) except: pass legend = ax.legend(legend_list,label_list , \ bbox_to_anchor=(.95, 1.355), loc=1, borderaxespad=0.0, prop={'size':10.3},frameon=False,numpoints=1, \ title="EXPLANATION") legend.get_title().set_position((-340, 0)) plt.savefig('b')
def multi_water_level(self,path,title, mode='Raw'): self.create_header() ax = self.figure.add_subplot(self.grid_spec[1,0:]) pos1 = ax.get_position() # get the original position pos2 = [pos1.x0, pos1.y0, pos1.width, pos1.height + .06] ax.set_position(pos2) # set a new position #create the second graph title first_title = "%s %s Water Level Time Series Comparison" % (title, mode) titleText = ax.text(0.5, 1.065,first_title, \ va='center', ha='center', transform=ax.transAxes) ax.set_ylabel('Water Level in Feet') ax.set_xlabel('Timezone GMT') #plot major grid lines ax.grid(b=True, which='major', color='grey', linestyle="-") #x axis formatter for dates (function format_date() below) ax.xaxis.set_major_formatter(ticker.FuncFormatter(self.format_date)) legend_list, label_list = [], [] air, sea, sea_file, air_file = False, False, '', '' file_types = ['.nc'] for root, sub_folders, files in os.walk(path): for file_in_root in files: index = file_in_root.rfind('.') if file_in_root[index:] in file_types: file = ''.join([root,'\\',file_in_root]) try: nc.get_pressure(file) sea = True sea_file = file except: try: nc.get_air_pressure(file) air = True air_file = file except: pass if sea and air: sea, air = False, False so = StormOptions() so.air_fname = air_file so.sea_fname = sea_file so.timezone = 'GMT' so.daylight_savings = False so.get_meta_data() so.get_air_meta_data() so.get_raw_water_level() so.get_surge_water_level() so.test_water_elevation_below_sensor_orifice_elvation() so.get_wave_water_level() first_date = unit_conversion.convert_ms_to_date(so.sea_time[0], pytz.UTC) last_date = unit_conversion.convert_ms_to_date(so.sea_time[-1], pytz.UTC) first_date = mdates.date2num(first_date) last_date = mdates.date2num(last_date) self.time_nums = np.linspace(first_date, last_date, len(so.sea_time)) lat = nc.get_variable_data(sea_file, 'latitude') lon = nc.get_variable_data(sea_file, 'longitude') stn_id = nc.get_global_attribute(sea_file, 'stn_instrument_id') stn_station = nc.get_global_attribute(sea_file, 'stn_station_number') if mode=='Surge': p1, = ax.plot(self.time_nums, so.surge_water_level, alpha=.5) legend_list.append(p1) label_list.append('STN Site ID: %s, STN Instrument ID: %s, Lat: %s, Lon: %s' \ %(stn_id, stn_station, lat, lon)) if mode=='Wave': p1, = ax.plot(self.time_nums, so.wave_water_level, alpha=.5) legend_list.append(p1) label_list.append('STN Site ID: %s, STN Instrument ID: %s, Lat: %s, Lon: %s' \ %(stn_id, stn_station, lat, lon)) if mode=='Raw': p1, = ax.plot(self.time_nums, so.raw_water_level, alpha=.5) legend_list.append(p1) label_list.append('STN Site ID: %s, STN Instrument ID: %s, Lat: %s, Lon: %s' \ %(stn_id, stn_station, lat, lon)) legend = ax.legend(legend_list,label_list , \ bbox_to_anchor=(.95, 1.355), loc=1, borderaxespad=0.0, prop={'size':10.3},frameon=False,numpoints=1, \ title="EXPLANATION") legend.get_title().set_position((-340, 0)) plt.savefig(''.join([title,mode]))