Skip to content

Commit

Permalink
fix number formats in strings and magicMoc error
Browse files Browse the repository at this point in the history
  • Loading branch information
nicHoch committed Nov 1, 2023
1 parent 2461c8d commit 091e8d4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
11 changes: 9 additions & 2 deletions stixcore/io/fits/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
NAN = 2 ** 32 - 1


def version_format(version):
# some very strange work around for direct use of format '{0:02d}'.format(version)
# as this is not supported by magicMoc
return f'{version:02d}'


def set_bscale_unsigned(table_hdu):
"""
Set bscale value to 1 if unsigned int.
Expand Down Expand Up @@ -96,10 +102,11 @@ def generate_filename(cls, product, *, version, date_range, status='', header=Tr
status = 'U'

return f'solo_{product.level}_stix-{product.type}-{product.name.replace("_", "-")}' \
f'_{date_range}_V{version:02d}{status}{user_req}{tc_control}.fits'
f'_{date_range}_V{version_format(version)}{status}{user_req}{tc_control}.fits'

@classmethod
def generate_common_header(cls, filename, product, *, version=0):

headers = (
# Name, Value, Comment
('FILENAME', filename, 'FITS filename'),
Expand All @@ -115,7 +122,7 @@ def generate_common_header(cls, filename, product, *, version=0):
('CREATOR', 'stixcore', 'FITS creation software'),
('VERS_SW', str(stixcore.__version__), 'Version of SW that provided FITS file'),
# ('VERS_CAL', '', 'Version of the calibration pack'),
('VERSION', f'{version:02d}', 'Version of data product'),
('VERSION', version_format(version), 'Version of data product'),
('OBSRVTRY', 'Solar Orbiter', 'Satellite name'),
('TELESCOP', 'SOLO/STIX', 'Telescope/Sensor name'),
('INSTRUME', 'STIX', 'Instrument name'),
Expand Down
5 changes: 4 additions & 1 deletion stixcore/processing/tests/test_publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,15 @@ def test_publish_fits_to_esa_incomplete(product, out_dir):
product.date_end = end
product.split_to_files.return_value = [product]
product.get_energies = False
product.get_processing_version.return_value = 1

files.extend(processor.write_fits(product))

assert len(files) == 3
# this was processed with predicted and flown
assert fits.getval(files[0], 'SPICE_MK') ==\
"solo_ANC_soc-pred-mk_V106_20201116_001.tm, solo_ANC_soc-flown-mk_V105_20200515_001.tm"
# the filename should be mared as incomplete
# the filename should be marked as incomplete
assert get_complete_file_name(files[0].name) != files[0].name
assert get_incomplete_file_name(files[0].name) == files[0].name

Expand Down Expand Up @@ -219,6 +220,7 @@ def test_fits_incomplete_switch_over(out_dir):
product.date_end = end
product.split_to_files.return_value = [product]
product.get_energies = False
product.get_processing_version.return_value = 1

files_first.extend(processor.write_fits(product))

Expand Down Expand Up @@ -338,6 +340,7 @@ def test_publish_fits_to_esa(product, out_dir):
product.date_beg = beg
product.date_end = end
product.split_to_files.return_value = [product]
product.get_processing_version.return_value = 1
product.get_energies = False

data = product.data[:] # make a clone
Expand Down

0 comments on commit 091e8d4

Please sign in to comment.