Skip to content

Commit

Permalink
Merge latest changes for 'estimator' into 'devel'.
Browse files Browse the repository at this point in the history
  • Loading branch information
purplecat7 committed Jul 24, 2023
2 parents d643109 + f5ca72b commit 44aabf8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
21 changes: 17 additions & 4 deletions DQTools/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def __repr__(self):
last_gold=self.last_gold,
data=self.data)

# TODO re-instate this once we ditch support for Python 3.5
# TODO re-instate this once we ditch support for Python 2.7
# return f"""<DQ Dataset: {self.product}-{self.subproduct}>
# ================================================================================
# Product: {self.product}
Expand Down Expand Up @@ -348,18 +348,31 @@ def get_data(self, start, stop,
print("Failed to retrieve Dataset sub-product DASK pointer, "
"please see logfile for details.")

def put(self):
def put(self, tile=None):
"""
Prepare self.data and metadata and send to the datacube.
Prepare self.data and metadata, then send to the datacube.
:param tile: Optionally provide the tile for the data. If not present,
the tile specified in the Dataset creation will be used.
The tile name will be checked against those for which the
Dataset is registered.
:return:
"""

try:
# Add product as an attribute to the data which will be written
self.data.attrs['product'] = self.product

# Ensure we specify the tile in the attributes
if not tile:
self.data.attrs['tile'] = self.tile
else:
if tile in self.all_subproduct_tiles:
self.data.attrs['tile'] = tile
else:
raise NameError("tile name must be valid for this product")

# Process last gold. This value needs to go into the DataArray
# attributes. The user could set them here, in the the DataSet
# attributes. The user could set them here, in the DataSet
# attributes or in self.data.attrs. Easiest if we just catch and
# process all possibilities.
if 'last_gold' not in self.data[self.subproduct].attrs or \
Expand Down
9 changes: 7 additions & 2 deletions Getting Started/new_subproduct_product.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ description: >
For testing. Please delete me.
keywords: delete test deleteme
link:
srid:
time_agg: month
x_blocksize: 256
y_blocksize: 256

subproducts:
- name: temp_diff
long_name: Surface-Air temperature difference
Expand All @@ -14,7 +17,9 @@ subproducts:
precision: 0.01
keywords: temperature difference
fill_value: -999
frequency: 3h
link:
time_resolution: 3h
xres: 0.05
yres: 0.05
tiles:
- madagascar
3 changes: 2 additions & 1 deletion Getting Started/new_tiles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
54.0 -10.0 0,
54.0 -27.0 0,
42.0 -27.0 0,
42.0 -10.0 0))
42.0 -10.0 0))
srid: 4326

0 comments on commit 44aabf8

Please sign in to comment.