From 12b346eb11537f05e45eaabe9171529fe6de164a Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@8a9318a1-56ba-4d59-b755-99d26321be01> Date: Fri, 22 Jan 2010 20:16:14 +0000 Subject: [PATCH] fixing bugs for colocation on command line, removing old filter that is not needed git-svn-id: https://svn.ssec.wisc.edu/repos/glance/trunk@104 8a9318a1-56ba-4d59-b755-99d26321be01 --- pyglance/glance/compare.py | 9 ++++++-- pyglance/glance/figures.py | 3 +-- pyglance/glance/filters.py | 45 ++++++++------------------------------ pyglance/glance/io.py | 8 +++++++ 4 files changed, 25 insertions(+), 40 deletions(-) diff --git a/pyglance/glance/compare.py b/pyglance/glance/compare.py index 7ff94c9..6541956 100644 --- a/pyglance/glance/compare.py +++ b/pyglance/glance/compare.py @@ -1165,9 +1165,9 @@ def reportGen_library_call (a_path, b_path, var_list=[ ], # multidimentional information requiring careful sampling if ('binIndex' in varRunInfo) and ('tupleIndex' in varRunInfo) : plotFunctionGenerationObjects.append(plotcreate.BinTupleAnalysisFunctionFactory()) - + else : - + # if the data is the same size, we can always make our basic statistical comparison plots if (aData.shape == bData.shape) : plotFunctionGenerationObjects.append(plotcreate.BasicComparisonPlotsFunctionFactory()) @@ -1632,6 +1632,11 @@ python -m glance tempOptions['epsilon'] = options.epsilon tempOptions['missing'] = options.missing + # TODO, remove these eventually + tempOptions['htmlOnly'] = False + tempOptions['imagesOnly'] = False + tempOptions['doFork'] = False + tempOptions['doColocate'] = True colocateToFile_library_call(args[0], args[1], args[2:], tempOptions) diff --git a/pyglance/glance/figures.py b/pyglance/glance/figures.py index f9d129c..45edc65 100644 --- a/pyglance/glance/figures.py +++ b/pyglance/glance/figures.py @@ -46,7 +46,7 @@ greenColorMapData = { } greenColorMap = colors.LinearSegmentedColormap('greenColorMap', greenColorMapData, 256) -# todo, the use off the offset here is covering a problem with +# todo, the use of the offset here is covering a problem with # contourf hiding data exactly at the end of the range and should # be removed if a better solution can be found def _make_range(data_a, invalid_a_mask, num_intervals, offset_to_range=0.0, data_b=None, invalid_b_mask=None) : @@ -66,7 +66,6 @@ def _make_range(data_a, invalid_a_mask, num_intervals, offset_to_range=0.0, data minVal = min(delta.min_with_mask(data_b, invalid_b_mask), minVal) maxVal = max(delta.max_with_mask(data_b, invalid_b_mask), maxVal) - minVal = minVal - offset_to_range maxVal = maxVal + offset_to_range diff --git a/pyglance/glance/filters.py b/pyglance/glance/filters.py index da9294c..2c550b3 100644 --- a/pyglance/glance/filters.py +++ b/pyglance/glance/filters.py @@ -133,6 +133,14 @@ def rotate_indexes_right (data) : note: at the moment this filter only works with 3 dimentional data sets """ + # figure out the new order of the indexes + numDims = len(data.shape) + newIndexOrder = [numDims - 1] + range(numDims - 1) + + # reorder the data + data_new = data.transpose(newIndexOrder) + + """ # figure out the shapes we have/need old_shape = data.shape #print ('old shape: ' + str(old_shape)) @@ -148,6 +156,7 @@ def rotate_indexes_right (data) : for index2 in range(old_shape[1]) : for index3 in range(old_shape[2]) : data_new[index3, index1, index2] = data[index1, index2, index3] + """ return data_new @@ -187,42 +196,6 @@ def filter_based_on_additional_data_set_min_max_bounds(data, filterData, missing return newData -def collapse_to_index(data, index, collapsing_function=np.mean, - missing_value=None, ignore_below_exclusive=None, ignore_above_exclusive=None) : - """ - collapse the data given along the selected index, using the collapsing_function - """ - - # figure the order to put the index we want first - new_index_order = range(len(data.shape)) - del(new_index_order[index]) - new_index_order = [index] + new_index_order - - # copy our data and put the index we won't collapse first - new_data = data.copy() - new_data = new_data.transpose(new_index_order) - - # find any bad points that we don't want to collapse - bad_mask = ~np.isfinite(new_data) - if missing_value is not None : - bad_mask[new_data == missing_value] = True - if ignore_above_exclusive is not None : - bad_mask[new_data > ignore_above_exclusive] = True - if ignore_below_exclusive is not None : - bad_mask[new_data < ignore_below_exclusive] = True - - # collapse any non bad data - final_num_pts = new_data.shape[0] - collapsed_data = np.zeros((final_num_pts), dtype=new_data.dtype) - for index_1_val in range(final_num_pts) : - values_to_use = new_data[index_1_val][~(bad_mask[index_1_val])] - if len(values_to_use) > 0 : - collapsed_data[index_1_val] = collapsing_function(values_to_use) - else: - collapsed_data[index_1_val] = missing_value - - return collapsed_data - def organize_ipopp_data_into_image(original_ipopp_data, wave_number=None, missing_value=None, propagate_partial_missing_values=False) : """ diff --git a/pyglance/glance/io.py b/pyglance/glance/io.py index a8bb795..eb112fd 100644 --- a/pyglance/glance/io.py +++ b/pyglance/glance/io.py @@ -227,6 +227,11 @@ class nc(CDF): LOG.warn("New variable name requested (" + variablename + ") is already present in file. " + "Skipping generation of new variable.") return None + # if we have no data we won't be able to determine the data type to create the variable + if (data is None) or (len(data) <= 0) : + LOG.warn("Data type for new variable (" + variablename + ") could not be determined. " + + "Skipping generation of new variable.") + return None dataType = None if np.issubdtype(data.dtype, int) : @@ -249,6 +254,9 @@ class nc(CDF): dimensionNum = dimensionNum + 1 # create the new variable + #print('variable name: ' + variablename) + #print('data type: ' + str(dataType)) + #print('dimensions: ' + str(dimensions)) newVariable = self.def_var(variablename, dataType, tuple(dimensions)) # if a missing value was given, use that -- GitLab