Skip to content

Commit

Permalink
moved output attrs to json file and included in setup package data
Browse files Browse the repository at this point in the history
  • Loading branch information
grantbuster committed Sep 12, 2024
1 parent 83d6475 commit a5f42b8
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 144 deletions.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def run(self):
"data_collect_cli:main"),
],
},
package_data={'sup3r': ['postprocessing/writers/*.json']},
test_suite="tests",
cmdclass={"develop": PostDevelopCommand},
)
149 changes: 5 additions & 144 deletions sup3r/postprocessing/writers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,150 +24,11 @@

logger = logging.getLogger(__name__)

OUTPUT_ATTRS = {
'u': {
'scale_factor': 100.0,
'units': 'm s-1',
'dtype': 'uint16',
'chunks': (2000, 500),
'min': -120,
'max': 120,
},
'v': {
'scale_factor': 100.0,
'units': 'm s-1',
'dtype': 'uint16',
'chunks': (2000, 500),
'min': -120,
'max': 120,
},
'windspeed': {
'scale_factor': 100.0,
'units': 'm s-1',
'dtype': 'uint16',
'chunks': (2000, 500),
'min': 0,
'max': 120,
},
'winddirection': {
'scale_factor': 100.0,
'units': 'degree',
'dtype': 'uint16',
'chunks': (2000, 500),
'min': 0,
'max': 360,
},
'clearsky_ratio': {
'scale_factor': 10000.0,
'units': 'ratio',
'dtype': 'uint16',
'chunks': (2000, 500),
'min': 0,
'max': 1,
},
'dhi': {
'scale_factor': 1.0,
'units': 'W/m2',
'dtype': 'uint16',
'chunks': (2000, 500),
'min': 0,
'max': 1350,
},
'dni': {
'scale_factor': 1.0,
'units': 'W/m2',
'dtype': 'uint16',
'chunks': (2000, 500),
'min': 0,
'max': 1350,
},
'ghi': {
'scale_factor': 1.0,
'units': 'W/m2',
'dtype': 'uint16',
'chunks': (2000, 500),
'min': 0,
'max': 1350,
},
'rsds': {
'scale_factor': 1.0,
'units': 'W/m2',
'dtype': 'uint16',
'chunks': (2000, 500),
'min': 0,
'max': 1350,
},
'temperature': {
'scale_factor': 100.0,
'units': 'C',
'dtype': 'int16',
'chunks': (2000, 500),
'min': -200,
'max': 100,
},
'temperature_min': {
'scale_factor': 100.0,
'units': 'C',
'dtype': 'int16',
'chunks': (2000, 500),
'min': -200,
'max': 100,
},
'temperature_max': {
'scale_factor': 100.0,
'units': 'C',
'dtype': 'int16',
'chunks': (2000, 500),
'min': -200,
'max': 100,
},
'relativehumidity': {
'scale_factor': 100.0,
'units': 'percent',
'dtype': 'uint16',
'chunks': (2000, 500),
'max': 100,
'min': 0,
},
'relativehumidity_min': {
'scale_factor': 100.0,
'units': 'percent',
'dtype': 'uint16',
'chunks': (2000, 500),
'max': 100,
'min': 0,
},
'relativehumidity_max': {
'scale_factor': 100.0,
'units': 'percent',
'dtype': 'uint16',
'chunks': (2000, 500),
'max': 100,
'min': 0,
},
'pressure': {
'scale_factor': 0.1,
'units': 'Pa',
'dtype': 'uint16',
'chunks': (2000, 500),
'min': 0,
'max': 150000,
},
'pr': {
'scale_factor': 1,
'units': 'kg m-2 s-1',
'dtype': 'float32',
'min': 0,
'chunks': (2000, 250),
},
'srl': {
'scale_factor': 1,
'units': 'm',
'dtype': 'float32',
'min': 0,
'chunks': (2000, 250),
},
}

ATTR_DIR = os.path.dirname(os.path.realpath(__file__))
ATTR_FP = os.path.join(ATTR_DIR, 'output_attrs.json')
with open(ATTR_FP, 'r') as f:
OUTPUT_ATTRS = json.load(f)


class OutputMixin:
Expand Down
144 changes: 144 additions & 0 deletions sup3r/postprocessing/writers/output_attrs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
{
"u": {
"scale_factor": 100.0,
"units": "m s-1",
"dtype": "uint16",
"chunks": [2000, 500],
"min": -120,
"max": 120
},
"v": {
"scale_factor": 100.0,
"units": "m s-1",
"dtype": "uint16",
"chunks": [2000, 500],
"min": -120,
"max": 120
},
"windspeed": {
"scale_factor": 100.0,
"units": "m s-1",
"dtype": "uint16",
"chunks": [2000, 500],
"min": 0,
"max": 120
},
"winddirection": {
"scale_factor": 100.0,
"units": "degree",
"dtype": "uint16",
"chunks": [2000, 500],
"min": 0,
"max": 360
},
"clearsky_ratio": {
"scale_factor": 10000.0,
"units": "ratio",
"dtype": "uint16",
"chunks": [2000, 500],
"min": 0,
"max": 1
},
"dhi": {
"scale_factor": 1.0,
"units": "W/m2",
"dtype": "uint16",
"chunks": [2000, 500],
"min": 0,
"max": 1350
},
"dni": {
"scale_factor": 1.0,
"units": "W/m2",
"dtype": "uint16",
"chunks": [2000, 500],
"min": 0,
"max": 1350
},
"ghi": {
"scale_factor": 1.0,
"units": "W/m2",
"dtype": "uint16",
"chunks": [2000, 500],
"min": 0,
"max": 1350
},
"rsds": {
"scale_factor": 1.0,
"units": "W/m2",
"dtype": "uint16",
"chunks": [2000, 500],
"min": 0,
"max": 1350
},
"temperature": {
"scale_factor": 100.0,
"units": "C",
"dtype": "int16",
"chunks": [2000, 500],
"min": -200,
"max": 100
},
"temperature_min": {
"scale_factor": 100.0,
"units": "C",
"dtype": "int16",
"chunks": [2000, 500],
"min": -200,
"max": 100
},
"temperature_max": {
"scale_factor": 100.0,
"units": "C",
"dtype": "int16",
"chunks": [2000, 500],
"min": -200,
"max": 100
},
"relativehumidity": {
"scale_factor": 100.0,
"units": "percent",
"dtype": "uint16",
"chunks": [2000, 500],
"max": 100,
"min": 0
},
"relativehumidity_min": {
"scale_factor": 100.0,
"units": "percent",
"dtype": "uint16",
"chunks": [2000, 500],
"max": 100,
"min": 0
},
"relativehumidity_max": {
"scale_factor": 100.0,
"units": "percent",
"dtype": "uint16",
"chunks": [2000, 500],
"max": 100,
"min": 0
},
"pressure": {
"scale_factor": 0.1,
"units": "Pa",
"dtype": "uint16",
"chunks": [2000, 500],
"min": 0,
"max": 150000
},
"pr": {
"scale_factor": 1,
"units": "kg m-2 s-1",
"dtype": "float32",
"min": 0,
"chunks": [2000, 250]
},
"srl": {
"scale_factor": 1,
"units": "m",
"dtype": "float32",
"min": 0,
"chunks": [2000, 250]
}
}

0 comments on commit a5f42b8

Please sign in to comment.