From e36ea75d463b8bbec784fe549fec96bd4a8f2412 Mon Sep 17 00:00:00 2001 From: jjd5150 Date: Wed, 13 Jul 2016 19:13:42 -0400 Subject: [PATCH 1/5] Add files via upload This is the new class for managing multiple datasets and eventually multiple files. Still in development, not ready for prime time --- calipso/vocalDataBlock.py | 246 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 246 insertions(+) create mode 100644 calipso/vocalDataBlock.py diff --git a/calipso/vocalDataBlock.py b/calipso/vocalDataBlock.py new file mode 100644 index 0000000..970fcf1 --- /dev/null +++ b/calipso/vocalDataBlock.py @@ -0,0 +1,246 @@ +from ccplot.algorithms import interp2d_12 +from ccplot.hdf import HDF +import ccplot.utils + +import matplotlib as mpl +import numpy as np +from matplotlib.figure import Figure + + + +class dataSet(): + + def __init__(self, in_type, in_data_set, in_xrange_time, in_xrange_coordinates, in_yrange, in_wavelength = 532): + self._type = in_type + self._wavelength = in_wavelength + self._data_set = in_data_set + self._xrange_time = in_xrange + self._yrange = in_yrange + self._fig = Figure + + + + + + +class vocalDataBlock(): + + def __init__(self, filename): + + self.__filename = filename + self.__data_sets = list() + + with HDF(filename) as product: + self.__x_time = np.array([ccplot.utils.calipso_time2dt(t) for t in product['Profile_UTC_Time'][::]]) + self.__record_count = len(self.__x_time) + self.__y_altitude = product['metadata']['Lidar_Data_Altitudes'][::] + self.__x_coordinates = [product['Longitude'][::],[product['Latitude'][::]]] + self.__day_night_flag = product['Day_Night_Flag'][::] + self.__working_type = [0,0] + self.__working_time = [0,0] + self.__working_coordinates = [0,0] + self.__working_altitude = [0,0] + self.__working_wavelength = 532 + + if "V4" in filename: + self.__version = "4" + else: + self.__file_version = "3" + + if "L1" in filename: + self.__data_level = "1" + else: + self.__data_level = "2" + + self.__data_sets = [] + + +"""Following is simple setters/getters associated with vocalDataBlock Class""" + #return the value of the minimum Y range (Altitude) + def get_y_min(self): + return self.__y_altitude[0] + + # return the value of the maximum Y range (Altitude) + def get_y_max(self): + return self.__y_altitude[-1] + + # return the value of the minimum X range (Time) + def get_x_time_min(self): + return self.__x_time[0] + + # return the value of the maximum X range (Time) + def get_x_time_max(self): + return self.__x_time[-1] + + # return the value of the minimum X range (Coordinate pair [long, lat]) + def get_x_coordinates_min(self): + return [self.__x_coordinates[0][0]],self.__x_coordinates[1][0] + + # return the value of the maximum X range (Coordinate pair [long, lat]) + def get_x_coordinates_max(self): + return [self.__x_coordinates[0][-1]],self.__x_coordinates[1][-1] + + # return the value at the iterator (in_x) from the time list + def get_time(self, in_x): + if in_x >= -1 and in_x <= self.__record_count: + return self.__x_time[in_x] + else: + '''Index Error''' + + # return the value at the iterator (in_x) from the coordinates list -- returns Coordinate pair [long, lat] + def get_coordinates(self, in_x): + if in_x >= -1 and in_x <= len(self.__record_count): + return self.__x_coordinates[in_x] + else: + '''Index Error''' + + # return the value at the iterator (in_y) from the altitude list + def get_altitude(self, in_y): + if in_y >= -1 and in_y <= len(self.__y_altitude): + return self.__y_altitude[in_y] + else: + '''Index Error''' + + # sets the working type as an integer - refer to constants.py for dictionary + def set_working_type(self, in_type): + if in_type >= 0 or in_type < 11: + self.__working_type = in_type + else: + '''Index Error''' + + # accepts a 2-element list of integers - This is the x range for a new data_set based off the working dataset + # since x can be represented by either coordinates (long,lat) or time, and setting of either working_time or + # working_coordinates updates both xtime and xcoordinates. This could be consolidated into one, but I believe + # it is best to seperate them for readability + def set_working_time(self, in_xtime): + if in_xtime[0] >= 0 and in_xtime[1] <= self.__record_count: + self.__working_coordinates = self.__working_time = in_xtime + else: + '''Index Error''' + + # accepts a 2-element list of integers - This is the x range for a new data_set based off the working dataset + # since x can be represented by either coordinates (long,lat) or time, and setting of either working_time or + # working_coordinates updates both xtime and xcoordinates. This could be consolidated into one, but I believe + # it is best to seperate them for readability + def set_working_coordinates(self, in_coordinates): + if in_coordinates[0] >= 0 and in_coordinates[1] <= self.__record_count: + self.__working_coordinates = self.__working_time = in_coordinates + + # This allows the setting of the wavelength as some datasets have 532 and 1064 wavelengths. + # The default is always 532 + def set_working_wavelength(self, in_wavelength): + if in_wavelength == '1064': + self.__working_wavelength = "1064" + else: + self.__working_wavelength = "532" + + # accepts a 2-element list of integers - This is the y range (altitude) for a new data_set based off the working dataset + def set_working_altitude(self, in_altitude): + if in_altitude[0] >= 0 and in_altitude[1] <= len(self.__y_altitude): + self.__working_altitude = in_altitude + else: + '''Index Error''' + """End simple setters/getters associated with vocalDataBlock Class""" + + # This will find the iterator for the working dataset within the dataset. It can also be used to check to see if the working dataset has already been created or if the list is empty + # return codes ('empty' == empty, "False" == does not exist in dataset, positive integer is a positive match and returns the iterator needed to access the dataset + # and negative interger is an iterator pointing to a dataset that the working dataset exists within + def find_iterator_in_dataset(self): + if len(self.__data_sets) == 0 + return "Empty" + else: + for i in self.__data_sets: + if self.__data_sets[i]._type == self.__working_type \ + and self.__data_sets[i]._wavelength == self.__working_wavelength \ + and self.__data_sets[i]._xrange_time == self.__working_time \ + and self.__data_sets[i]._yrange == self.__working_altitude: + return i + '''NOT IMPLEMENTED YET Not sure if I can use the iterators to determine if a set is within a set + elif + if ( self.__data_sets[i]._type == self.__working_type \ + and self.__data_sets[i]._wavelength == self.__working_wavelength) \ + and ( self.__working_altitude in self.__data_sets[i]._yrange \ + and self.__working_time in self.__data_sets[i]._xrange_time): + return (-1 * i)''' + + return "False" + + + + #Loads the needed color map + def load_color_map(self, in_type): + if in_type == 1: + colormap = 'dat/calipso-backscatter.cmap' + elif type == 2: + colormap = 'dat/calipso-depolar.cmap' + elif type == 3: + colormap = 'dat/calipso-vfm.cmap' + elif type == 4: + #colormap = 'dat/calipso-undefined.cmap' + elif type == 5: + #colormap = 'dat/calipso-undefined.cmap' + elif type == 6: + #colormap = 'dat/calipso-undefined.cmap' + elif type == 7: + #colormap = 'dat/calipso-undefined.cmap' + elif type == 8: + #colormap = 'dat/calipso-undefined.cmap' + elif type == 9: + #colormap = 'dat/calipso-undefined.cmap' + elif type == 10: + #colormap = 'dat/calipso-undefined.cmap' + else: + colormap = "" + ###UNKNOWN COLORMAP### + cmap = ccplot.utils.cmap(colormap) + cm = mpl.colors.ListedColormap(cmap['colors']/255.0) + cm.set_under(cmap['under'] / 255.0) + cm.set_over(cmap['over'] / 255.0) + cm.set_bad(cmap['bad'] / 255.0) + return [cm, mpl.colors.BoundaryNorm(cmap['bounds'], cm.N)] + + + def load_dataset(self, in_dataset_to_get): + dataset_iterator = self.find_iterator_in_dataset() + if dataset_iterator == "False" or dataset_iterator == "Empty": + with HDF(self.__filename) as product: + return product[in_dataset_to_get][self.__working_time[0], self.__working_time[1]] + + else: + return self.__datasets[dataset_iterator]._data_set[self.__working_time[0], self.__working_time[1]] + + + def backscatter(self): + if self.__working_wavelength == "1064": + dataset_to_get = 'Total_Attenuated_Backscatter_1064' + else: + dataset_to_get = 'Total_Attenuated_Backscatter_532' + + + data = np.ma.masked_equal(load_dataset(self,dataset_to_get), -9999) + + _x = np.arange(x1, x2, dtype=np.float32) + _y, null = np.meshgrid(height, _x) + data = interp2d_12( + data[::], + _x.astype(np.float32), + _y.astype(np.float32), + x1, x2, x2 - x1, + h2, h1, nz, +) + +'''TODO List +def append_Data_Sets(self, in_type, in_data_set, in_wavelength="532"): +def remove_Data_Sets(self, in_type, in_data_set, in_wavelength="532"): +def update_Data_Sets(self, in_type, in_data_set, in_wavelength="532"): +def depolarization(self): +def vfm(self): +''' + + + + + + + + From 61c7c7cc221451768654ac9beefc7284079b3158 Mon Sep 17 00:00:00 2001 From: Moore Date: Thu, 21 Jul 2016 11:59:27 -0400 Subject: [PATCH 2/5] working on adding longitude range into database --- calipso/importdialog.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/calipso/importdialog.py b/calipso/importdialog.py index 177a781..f899402 100644 --- a/calipso/importdialog.py +++ b/calipso/importdialog.py @@ -69,7 +69,9 @@ def __init__(self, root, master): self.end_time = None self.beg_lat = None self.end_lat = None - self.beg_alt = None + #self.beg_long = None + #self.end_long = None + self.beg_alt = None self.end_alt = None self.file = None @@ -187,7 +189,8 @@ def get_current_file_shapes(self): time_range = '%s - %s' % (obj.begin_time.strftime(DATEFORMAT), obj.end_time.strftime('%H:%M:%S')) altitude_range = '%.3f - %.3f' % (obj.begin_alt, obj.end_alt) lat_range = '%.3f - %.3f' % (obj.begin_lat, obj.end_lat) - lst.append( + #long_range = '(%.3f) - (%.3f)' % (obj.begin_long, obj.end_long) + lst.append( (obj.tag, obj.plot, time_range, lat_range, altitude_range, obj.attributes[1:-1], obj.notes, obj.time_.strftime(DATEFORMAT), obj.hdf)) if not lst: @@ -230,6 +233,7 @@ def refine_search(self, event): time_range = '%s - %s' % (obj.begin_time.strftime(DATEFORMAT), obj.end_time.strftime('%H:%M:%S')) altitude_range = '%.3f - %.3f' % (obj.begin_alt, obj.end_alt) lat_range = '%.3f - %.3f' % (obj.begin_lat, obj.end_lat) + #long_range = '(%.3f) - (%.3f)' % (obj.begin_long, obj.end_long) lst.append( # append any objects that were returned by the query (obj.tag, obj.plot, time_range, lat_range, altitude_range, obj.attributes[1:-1], obj.notes, obj.time_.strftime(DATEFORMAT), obj.hdf)) @@ -322,6 +326,7 @@ def __display_all(self): time_range = '%s - %s' % (obj.begin_time.strftime(DATEFORMAT), obj.end_time.strftime('%H:%M:%S')) altitude_range = '%.3f - %.3f' % (obj.begin_alt, obj.end_alt) lat_range = '%.3f - %.3f' % (obj.begin_lat, obj.end_lat) + #long_range = '(%.3f) - (%.3f)' % (obj.begin_long, obj.end_long) lst.append( # user see's this list (obj.tag, obj.plot, time_range, lat_range, altitude_range, obj.attributes[1:-1], obj.notes, obj.time_.strftime(DATEFORMAT), obj.hdf)) @@ -350,6 +355,8 @@ def receive_advanced_search(self, observer): etime -> '00-00-00' -> hr-m-s -> Ending time range blat -> '0.0' -> float -> Beginning latitude range (*blat* -> *elat*) elat -> '0.0' -> float -> Ending latitude range + blong -> '0.0' -> float -> Beginning longitude range (*blong* -> *elat*) + elong -> '0.0' -> float -> Ending longitude range balt -> '0.0' -> float -> Beginning altitude range (*balt* -> *ealt*) ealt -> '0.0' -> float -> Ending altitude range plot -> PLOTS -> string -> Type of plot ('backscattered' etc..) @@ -388,7 +395,17 @@ def receive_advanced_search(self, observer): DatabasePolygon.end_lat <= rng['elat'] ) - if rng['balt']: + #if rng['blong']: + # query_result = query_result.filter( + # DatabasePolygon.begin_long >= rng['blong'] + # ) + + #if rng['elong']: + # query_result = query_result.filter( + # DatabasePolygon.end_long >= rng['elong'] + # ) + + if rng['balt']: query_result = query_result.filter( DatabasePolygon.begin_alt >= rng['balt'] ) @@ -404,6 +421,7 @@ def receive_advanced_search(self, observer): time_range = '%s - %s' % (obj.begin_time.strftime(DATEFORMAT), obj.end_time.strftime('%H:%M:%S')) altitude_range = '%.3f - %.3f' % (obj.begin_alt, obj.end_alt) lat_range = '%.3f - %.3f' % (obj.begin_lat, obj.end_lat) + #long_range = '(%.3f) - (%.3f)' % (obj.begin_long, obj.end_long) # If we're parsing a date, we can't just filter as we must transform # coordinates into time_range first, so we need to manually check and # skip which is PROBABLY not the best solution. From 4d1862e5ce6e1a73cec898b3d5e2ebf6c496f5ef Mon Sep 17 00:00:00 2001 From: Moore Date: Thu, 21 Jul 2016 14:16:43 -0400 Subject: [PATCH 3/5] Added longitude to display on backscattered and depolarized; flipped depolarized's x-axes to match. --- calipso/plot/plot_backscattered.py | 13 ++++++++++++- calipso/plot/plot_depolar_ratio.py | 24 +++++++++++++----------- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/calipso/plot/plot_backscattered.py b/calipso/plot/plot_backscattered.py index 9a9c3e0..bd859cc 100644 --- a/calipso/plot/plot_backscattered.py +++ b/calipso/plot/plot_backscattered.py @@ -11,6 +11,7 @@ import ccplot.utils import matplotlib as mpl +#import matplotlib.pyplot as plt #KDM import numpy as np @@ -37,6 +38,7 @@ def render_backscattered(filename, x_range, y_range, fig, pfig): height = product['metadata']['Lidar_Data_Altitudes'] dataset = product['Total_Attenuated_Backscatter_532'][x1:x2] latitude = product['Latitude'][x1:x2, 0] + longitude = product['Longitude'][x1:x2, 0] time = np.array([ccplot.utils.calipso_time2dt(t) for t in time]) dataset = np.ma.masked_equal(dataset, -9999) @@ -84,7 +86,16 @@ def render_backscattered(filename, x_range, y_range, fig, pfig): ax.set_xlabel('Time') ax.set_xlim(time[0], time[-1]) ax.get_xaxis().set_major_formatter(mpl.dates.DateFormatter('%H:%M:%S')) - + + # KDM - added longitude axis below + long_ax = fig.twiny() + long_ax.xaxis.set_ticks_position('bottom') + long_ax.xaxis.set_label_position('bottom') + long_ax.spines['bottom'].set_position(('outward', 40)) + long_ax.set_xlim(longitude[0], longitude[-1]) + long_ax.set_xlabel('Longitude') + + fig.set_zorder(0) ax.set_zorder(1) diff --git a/calipso/plot/plot_depolar_ratio.py b/calipso/plot/plot_depolar_ratio.py index 502c5f2..9508b83 100644 --- a/calipso/plot/plot_depolar_ratio.py +++ b/calipso/plot/plot_depolar_ratio.py @@ -35,6 +35,7 @@ def render_depolarized(filename, x_range, y_range, fig, pfig): minimum = min(product['Profile_UTC_Time'][::])[0] maximum = max(product['Profile_UTC_Time'][::])[0] latitude = product['Latitude'][x1:x2, 0] + longitude = product['Longitude'][x1:x2, 0] # length of time determines how far the file can be viewed if time[-1] >= maximum and len(time) < 950: @@ -81,7 +82,7 @@ def render_depolarized(filename, x_range, y_range, fig, pfig): im = fig.imshow( regrid_depolar_ratio, - extent=(mpl.dates.date2num(time[0]), mpl.dates.date2num(time[-1]), h1, h2), + extent=(latitude[0], latitude[-1], h1, h2), cmap=cm, norm=norm, aspect='auto', @@ -89,21 +90,22 @@ def render_depolarized(filename, x_range, y_range, fig, pfig): ) fig.set_ylabel('Altitute (km)') - fig.set_xlabel('Time') - fig.get_xaxis().set_major_locator(mpl.dates.AutoDateLocator()) - fig.get_xaxis().set_major_formatter(mpl.dates.DateFormatter('%H:%M:%S')) - - # granule = "%sZ%s" % extractDatetime(filename) - # title = 'Depolarized Ratio for granule %s' % granule - # fig.set_title(title) - + fig.set_xlabel('Latitude') cbar_label = 'Depolarized Ratio 532nm (km$^{-1}$ sr$^{-1}$)' cbar = pfig.colorbar(im) cbar.set_label(cbar_label) ax = fig.twiny() - ax.set_xlabel('Latitude') - ax.set_xlim(latitude[0], latitude[-1]) + ax.set_xlabel('Time') + ax.set_xlim(time[0], time[-1]) + ax.get_xaxis().set_major_formatter(mpl.dates.DateFormatter('%H:%M:%S')) + + long_ax = fig.twiny() + long_ax.xaxis.set_ticks_position('bottom') + long_ax.xaxis.set_label_position('bottom') + long_ax.spines['bottom'].set_position(('outward', 40)) + long_ax.set_xlim(longitude[0], longitude[-1]) + long_ax.set_xlabel('Longitude') fig.set_zorder(1) ax.set_zorder(0) From 067b1f65cec430851e0c1436e0c1fa364a2488f7 Mon Sep 17 00:00:00 2001 From: Moore Date: Thu, 21 Jul 2016 14:21:08 -0400 Subject: [PATCH 4/5] removing a file from PR --- calipso/importdialog.py | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/calipso/importdialog.py b/calipso/importdialog.py index f899402..177a781 100644 --- a/calipso/importdialog.py +++ b/calipso/importdialog.py @@ -69,9 +69,7 @@ def __init__(self, root, master): self.end_time = None self.beg_lat = None self.end_lat = None - #self.beg_long = None - #self.end_long = None - self.beg_alt = None + self.beg_alt = None self.end_alt = None self.file = None @@ -189,8 +187,7 @@ def get_current_file_shapes(self): time_range = '%s - %s' % (obj.begin_time.strftime(DATEFORMAT), obj.end_time.strftime('%H:%M:%S')) altitude_range = '%.3f - %.3f' % (obj.begin_alt, obj.end_alt) lat_range = '%.3f - %.3f' % (obj.begin_lat, obj.end_lat) - #long_range = '(%.3f) - (%.3f)' % (obj.begin_long, obj.end_long) - lst.append( + lst.append( (obj.tag, obj.plot, time_range, lat_range, altitude_range, obj.attributes[1:-1], obj.notes, obj.time_.strftime(DATEFORMAT), obj.hdf)) if not lst: @@ -233,7 +230,6 @@ def refine_search(self, event): time_range = '%s - %s' % (obj.begin_time.strftime(DATEFORMAT), obj.end_time.strftime('%H:%M:%S')) altitude_range = '%.3f - %.3f' % (obj.begin_alt, obj.end_alt) lat_range = '%.3f - %.3f' % (obj.begin_lat, obj.end_lat) - #long_range = '(%.3f) - (%.3f)' % (obj.begin_long, obj.end_long) lst.append( # append any objects that were returned by the query (obj.tag, obj.plot, time_range, lat_range, altitude_range, obj.attributes[1:-1], obj.notes, obj.time_.strftime(DATEFORMAT), obj.hdf)) @@ -326,7 +322,6 @@ def __display_all(self): time_range = '%s - %s' % (obj.begin_time.strftime(DATEFORMAT), obj.end_time.strftime('%H:%M:%S')) altitude_range = '%.3f - %.3f' % (obj.begin_alt, obj.end_alt) lat_range = '%.3f - %.3f' % (obj.begin_lat, obj.end_lat) - #long_range = '(%.3f) - (%.3f)' % (obj.begin_long, obj.end_long) lst.append( # user see's this list (obj.tag, obj.plot, time_range, lat_range, altitude_range, obj.attributes[1:-1], obj.notes, obj.time_.strftime(DATEFORMAT), obj.hdf)) @@ -355,8 +350,6 @@ def receive_advanced_search(self, observer): etime -> '00-00-00' -> hr-m-s -> Ending time range blat -> '0.0' -> float -> Beginning latitude range (*blat* -> *elat*) elat -> '0.0' -> float -> Ending latitude range - blong -> '0.0' -> float -> Beginning longitude range (*blong* -> *elat*) - elong -> '0.0' -> float -> Ending longitude range balt -> '0.0' -> float -> Beginning altitude range (*balt* -> *ealt*) ealt -> '0.0' -> float -> Ending altitude range plot -> PLOTS -> string -> Type of plot ('backscattered' etc..) @@ -395,17 +388,7 @@ def receive_advanced_search(self, observer): DatabasePolygon.end_lat <= rng['elat'] ) - #if rng['blong']: - # query_result = query_result.filter( - # DatabasePolygon.begin_long >= rng['blong'] - # ) - - #if rng['elong']: - # query_result = query_result.filter( - # DatabasePolygon.end_long >= rng['elong'] - # ) - - if rng['balt']: + if rng['balt']: query_result = query_result.filter( DatabasePolygon.begin_alt >= rng['balt'] ) @@ -421,7 +404,6 @@ def receive_advanced_search(self, observer): time_range = '%s - %s' % (obj.begin_time.strftime(DATEFORMAT), obj.end_time.strftime('%H:%M:%S')) altitude_range = '%.3f - %.3f' % (obj.begin_alt, obj.end_alt) lat_range = '%.3f - %.3f' % (obj.begin_lat, obj.end_lat) - #long_range = '(%.3f) - (%.3f)' % (obj.begin_long, obj.end_long) # If we're parsing a date, we can't just filter as we must transform # coordinates into time_range first, so we need to manually check and # skip which is PROBABLY not the best solution. From 9a05323bb2d5ab2486586631e1e34ddecae446a0 Mon Sep 17 00:00:00 2001 From: kdottiemo Date: Mon, 8 Aug 2016 13:22:06 -0400 Subject: [PATCH 5/5] Delete vocalDataBlock.py --- calipso/vocalDataBlock.py | 246 -------------------------------------- 1 file changed, 246 deletions(-) delete mode 100644 calipso/vocalDataBlock.py diff --git a/calipso/vocalDataBlock.py b/calipso/vocalDataBlock.py deleted file mode 100644 index 970fcf1..0000000 --- a/calipso/vocalDataBlock.py +++ /dev/null @@ -1,246 +0,0 @@ -from ccplot.algorithms import interp2d_12 -from ccplot.hdf import HDF -import ccplot.utils - -import matplotlib as mpl -import numpy as np -from matplotlib.figure import Figure - - - -class dataSet(): - - def __init__(self, in_type, in_data_set, in_xrange_time, in_xrange_coordinates, in_yrange, in_wavelength = 532): - self._type = in_type - self._wavelength = in_wavelength - self._data_set = in_data_set - self._xrange_time = in_xrange - self._yrange = in_yrange - self._fig = Figure - - - - - - -class vocalDataBlock(): - - def __init__(self, filename): - - self.__filename = filename - self.__data_sets = list() - - with HDF(filename) as product: - self.__x_time = np.array([ccplot.utils.calipso_time2dt(t) for t in product['Profile_UTC_Time'][::]]) - self.__record_count = len(self.__x_time) - self.__y_altitude = product['metadata']['Lidar_Data_Altitudes'][::] - self.__x_coordinates = [product['Longitude'][::],[product['Latitude'][::]]] - self.__day_night_flag = product['Day_Night_Flag'][::] - self.__working_type = [0,0] - self.__working_time = [0,0] - self.__working_coordinates = [0,0] - self.__working_altitude = [0,0] - self.__working_wavelength = 532 - - if "V4" in filename: - self.__version = "4" - else: - self.__file_version = "3" - - if "L1" in filename: - self.__data_level = "1" - else: - self.__data_level = "2" - - self.__data_sets = [] - - -"""Following is simple setters/getters associated with vocalDataBlock Class""" - #return the value of the minimum Y range (Altitude) - def get_y_min(self): - return self.__y_altitude[0] - - # return the value of the maximum Y range (Altitude) - def get_y_max(self): - return self.__y_altitude[-1] - - # return the value of the minimum X range (Time) - def get_x_time_min(self): - return self.__x_time[0] - - # return the value of the maximum X range (Time) - def get_x_time_max(self): - return self.__x_time[-1] - - # return the value of the minimum X range (Coordinate pair [long, lat]) - def get_x_coordinates_min(self): - return [self.__x_coordinates[0][0]],self.__x_coordinates[1][0] - - # return the value of the maximum X range (Coordinate pair [long, lat]) - def get_x_coordinates_max(self): - return [self.__x_coordinates[0][-1]],self.__x_coordinates[1][-1] - - # return the value at the iterator (in_x) from the time list - def get_time(self, in_x): - if in_x >= -1 and in_x <= self.__record_count: - return self.__x_time[in_x] - else: - '''Index Error''' - - # return the value at the iterator (in_x) from the coordinates list -- returns Coordinate pair [long, lat] - def get_coordinates(self, in_x): - if in_x >= -1 and in_x <= len(self.__record_count): - return self.__x_coordinates[in_x] - else: - '''Index Error''' - - # return the value at the iterator (in_y) from the altitude list - def get_altitude(self, in_y): - if in_y >= -1 and in_y <= len(self.__y_altitude): - return self.__y_altitude[in_y] - else: - '''Index Error''' - - # sets the working type as an integer - refer to constants.py for dictionary - def set_working_type(self, in_type): - if in_type >= 0 or in_type < 11: - self.__working_type = in_type - else: - '''Index Error''' - - # accepts a 2-element list of integers - This is the x range for a new data_set based off the working dataset - # since x can be represented by either coordinates (long,lat) or time, and setting of either working_time or - # working_coordinates updates both xtime and xcoordinates. This could be consolidated into one, but I believe - # it is best to seperate them for readability - def set_working_time(self, in_xtime): - if in_xtime[0] >= 0 and in_xtime[1] <= self.__record_count: - self.__working_coordinates = self.__working_time = in_xtime - else: - '''Index Error''' - - # accepts a 2-element list of integers - This is the x range for a new data_set based off the working dataset - # since x can be represented by either coordinates (long,lat) or time, and setting of either working_time or - # working_coordinates updates both xtime and xcoordinates. This could be consolidated into one, but I believe - # it is best to seperate them for readability - def set_working_coordinates(self, in_coordinates): - if in_coordinates[0] >= 0 and in_coordinates[1] <= self.__record_count: - self.__working_coordinates = self.__working_time = in_coordinates - - # This allows the setting of the wavelength as some datasets have 532 and 1064 wavelengths. - # The default is always 532 - def set_working_wavelength(self, in_wavelength): - if in_wavelength == '1064': - self.__working_wavelength = "1064" - else: - self.__working_wavelength = "532" - - # accepts a 2-element list of integers - This is the y range (altitude) for a new data_set based off the working dataset - def set_working_altitude(self, in_altitude): - if in_altitude[0] >= 0 and in_altitude[1] <= len(self.__y_altitude): - self.__working_altitude = in_altitude - else: - '''Index Error''' - """End simple setters/getters associated with vocalDataBlock Class""" - - # This will find the iterator for the working dataset within the dataset. It can also be used to check to see if the working dataset has already been created or if the list is empty - # return codes ('empty' == empty, "False" == does not exist in dataset, positive integer is a positive match and returns the iterator needed to access the dataset - # and negative interger is an iterator pointing to a dataset that the working dataset exists within - def find_iterator_in_dataset(self): - if len(self.__data_sets) == 0 - return "Empty" - else: - for i in self.__data_sets: - if self.__data_sets[i]._type == self.__working_type \ - and self.__data_sets[i]._wavelength == self.__working_wavelength \ - and self.__data_sets[i]._xrange_time == self.__working_time \ - and self.__data_sets[i]._yrange == self.__working_altitude: - return i - '''NOT IMPLEMENTED YET Not sure if I can use the iterators to determine if a set is within a set - elif - if ( self.__data_sets[i]._type == self.__working_type \ - and self.__data_sets[i]._wavelength == self.__working_wavelength) \ - and ( self.__working_altitude in self.__data_sets[i]._yrange \ - and self.__working_time in self.__data_sets[i]._xrange_time): - return (-1 * i)''' - - return "False" - - - - #Loads the needed color map - def load_color_map(self, in_type): - if in_type == 1: - colormap = 'dat/calipso-backscatter.cmap' - elif type == 2: - colormap = 'dat/calipso-depolar.cmap' - elif type == 3: - colormap = 'dat/calipso-vfm.cmap' - elif type == 4: - #colormap = 'dat/calipso-undefined.cmap' - elif type == 5: - #colormap = 'dat/calipso-undefined.cmap' - elif type == 6: - #colormap = 'dat/calipso-undefined.cmap' - elif type == 7: - #colormap = 'dat/calipso-undefined.cmap' - elif type == 8: - #colormap = 'dat/calipso-undefined.cmap' - elif type == 9: - #colormap = 'dat/calipso-undefined.cmap' - elif type == 10: - #colormap = 'dat/calipso-undefined.cmap' - else: - colormap = "" - ###UNKNOWN COLORMAP### - cmap = ccplot.utils.cmap(colormap) - cm = mpl.colors.ListedColormap(cmap['colors']/255.0) - cm.set_under(cmap['under'] / 255.0) - cm.set_over(cmap['over'] / 255.0) - cm.set_bad(cmap['bad'] / 255.0) - return [cm, mpl.colors.BoundaryNorm(cmap['bounds'], cm.N)] - - - def load_dataset(self, in_dataset_to_get): - dataset_iterator = self.find_iterator_in_dataset() - if dataset_iterator == "False" or dataset_iterator == "Empty": - with HDF(self.__filename) as product: - return product[in_dataset_to_get][self.__working_time[0], self.__working_time[1]] - - else: - return self.__datasets[dataset_iterator]._data_set[self.__working_time[0], self.__working_time[1]] - - - def backscatter(self): - if self.__working_wavelength == "1064": - dataset_to_get = 'Total_Attenuated_Backscatter_1064' - else: - dataset_to_get = 'Total_Attenuated_Backscatter_532' - - - data = np.ma.masked_equal(load_dataset(self,dataset_to_get), -9999) - - _x = np.arange(x1, x2, dtype=np.float32) - _y, null = np.meshgrid(height, _x) - data = interp2d_12( - data[::], - _x.astype(np.float32), - _y.astype(np.float32), - x1, x2, x2 - x1, - h2, h1, nz, -) - -'''TODO List -def append_Data_Sets(self, in_type, in_data_set, in_wavelength="532"): -def remove_Data_Sets(self, in_type, in_data_set, in_wavelength="532"): -def update_Data_Sets(self, in_type, in_data_set, in_wavelength="532"): -def depolarization(self): -def vfm(self): -''' - - - - - - - -