Skip to content

Commit

Permalink
Merge branch 'master' into use-token-missing-methods
Browse files Browse the repository at this point in the history
  • Loading branch information
burnout87 committed Jul 12, 2023
2 parents 300aa6e + 402390f commit c68bbc1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
23 changes: 22 additions & 1 deletion oda_api/data_products.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,17 @@ def __init__(self, data, data_header={}, meta_data={}, hdu_type=None, name=None,
self.hdu_type=hdu_type
self.units_dict=units_dict

@property
def name(self):
return self._name

@name.setter
def name(self, name_value):
if name_value is None:
self._name = 'table'
else:
self._name = name_value

# interface with a typo, preserving with a warning
def _warn_chekc_typo(self):
logger.debug('please _check_* instead of _chekc_* functions, they will be removed')
Expand Down Expand Up @@ -288,6 +299,16 @@ def from_fits_hdu(cls,hdu,name=None):

def to_fits_hdu(self):
try:

logger.warning('------------------------------')
logger.warning('inside to_fits_hdu methods')
logger.warning(f'name: {self.name}')
logger.warning(f'header: {self.header}')
logger.warning(f'data: {self.data}')
logger.warning(f'units_dict: {self.units_dict}')
logger.warning(f'hdu_type: {self.hdu_type}')
logger.warning('------------------------------')

for k,v in self.header.items():
if isinstance(v, list):
s=''
Expand All @@ -301,7 +322,7 @@ def to_fits_hdu(self):
header=pf.header.Header(self.header),
hdu_type=self.hdu_type,units_dict=self.units_dict)
except Exception as e:
raise Exception("the platfrom encourntered a bug which happens when ScW list is sent as a file; we are working on it! raw message: "+repr(e))
raise Exception("an exception occurred in oda_api when binary products are formatted to fits header: " + repr(e))



Expand Down
7 changes: 7 additions & 0 deletions tests/test_data_products.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ def test_one_image():

assert np.all(ndu_decoded.data == data)

ndp.data_unit[1].name = None

hdu_list_obj = ndp.to_fits_hdu_list()

assert hdu_list_obj[0].name == 'PRIMARY'
assert hdu_list_obj[1].name == 'TABLE'


def test_variable_length_table():
from oda_api.data_products import NumpyDataProduct
Expand Down

0 comments on commit c68bbc1

Please sign in to comment.