Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/issue 44 #47

Merged
merged 6 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- update tig to be able to run with arm architecture
- ** Add image uploading **
- update tig to upload tig image to ecr
- ** Add palette support to generating configuration **
- [issue/44] (https://github.com/podaac/hitide/issues/44): Add support to palette, ppd, fill_missing in csv in generating configuration
### Changed
### Deprecated
### Removed
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ latitude: latitude variable include the group if they're in a group defaults to
time: time variable include the group if they're in a group defaults to time
footprint_strategy: strategy to generate footprint will default to None options should be ["periodic", "linestring", "polar", "swot_linestring", "polarsides", "smap"]

### CSV Columns

variable: name of variable
min: min value for variable
max: max value for variable
palette (optional): the palette to be used for the variable
fill_missing (optional): if the generated images have missing pixel in images most likely resolution is to big, either lower resolution or we can fill in the pixels with surrounding pixel
ppd (optional): resolution of the variable, must be an integer


## How to load and use tig module
Expand Down
6 changes: 3 additions & 3 deletions example_vars.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
variable,min,max
data_01/ku/ssha,-0.2,0.2
data_01/ku/swh_ocean,0,30
variable,min,max,palette,fill_missing,ppd
data_01/ku/ssha,-0.2,0.2,paletteMedspirationIndexed,TRUE,20
data_01/ku/swh_ocean,0,30,palette_AQUARIUS,FALSE,15
38 changes: 28 additions & 10 deletions podaac/tig/generate_hitide_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ def generate_hitide_config(granule, dataset_id, include_image_variables, longitu
's2': '0:*,*:*'
}

vars_min_max = {}
vars_data = {}
if include_image_variables:
vars_min_max = read_min_max_csv(include_image_variables)
vars_data = read_min_max_csv(include_image_variables)

with nc.Dataset(granule, 'r') as dataset: # pylint: disable=no-member

Expand All @@ -115,28 +115,46 @@ def generate_hitide_config(granule, dataset_id, include_image_variables, longitu

try:
for data_var in data_var_names:
if vars_min_max and data_var in vars_min_max:
if vars_data and data_var in vars_data:
variable = dataset[data_var]

units = variable.units if 'units' in variable.ncattrs() else ''
long_name = variable.long_name if 'long_name' in variable.ncattrs() else ''

if data_var in vars_min_max:
min_max = vars_min_max[data_var]
min_val = float(min_max['min'])
max_val = float(min_max['max'])
palette = 'paletteMedspirationIndexed'
fill_missing = False
ppd = 16

if data_var in vars_data:
min_val = float(vars_data[data_var]['min'])
max_val = float(vars_data[data_var]['max'])
palette = vars_data[data_var].get('palette')
fill_missing = vars_data[data_var].get('fill_missing', False)
ppd = vars_data[data_var].get('ppd', 16)
else:
min_val = variable.valid_min if 'valid_min' in variable.ncattrs() else ''
max_val = variable.valid_max if 'valid_max' in variable.ncattrs() else ''

dataset_config['imgVariables'].append({
if not palette:
palette = 'paletteMedspirationIndexed'

dataset_dict = {
'id': data_var,
'title': long_name,
'units': units,
'min': min_val,
'max': max_val,
'palette': 'paletteMedspirationIndexed'
})
'palette': palette
}

if fill_missing:
fill_missing = fill_missing.lower().strip()
dataset_dict['fill_missing'] = fill_missing == "true"

if ppd != 16 and ppd.isdigit():
dataset_dict['ppd'] = int(ppd)

dataset_config['imgVariables'].append(dataset_dict)

except Exception as ex: # pylint: disable=broad-exception-caught
print(f"Error: Failed on variable {data_var}, exception: " + str(ex))
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "podaac-tig"
version = "0.9.0-rc.0"
version = "0.9.0-alpha.4"
description = "Tool for Image Generation (TIG)"
authors = ["podaac-tva <podaac-tva@jpl.nasa.gov>"]
license = "Apache-2.0"
Expand Down
Loading