Пример #1
0
 def _check_local(self, f_name):
     self._logger.debug(f'Begin _check_local for {f_name}')
     file_id = obs_file_relationship.remove_extensions(f_name)
     try_these = [
         f'{file_id}.fits',
         f'{file_id}.fits.header',
         f'{file_id}.fits.bz2',
         f'{file_id}.fits.gz',
     ]
     result = None
     for data_source in self._data_sources:
         for f_name in try_these:
             fqn = path.join(data_source, f_name)
             if path.exists(fqn):
                 headers = data_util.get_local_file_headers(fqn)
                 temp = headers[0].get('DATALAB').upper()
                 if temp is not None:
                     result = headers[0].get('DATALAB')
                     self._logger.debug(
                         f'Found observation ID {result} for {f_name} on '
                         f'disk.'
                     )
                     break
     self._logger.debug('End _check_local')
     return result
Пример #2
0
def test_time_nan():
    test_obs = 'C120712_NGC7790_H_SCIRED'
    test_file = f'file://{TESTDATA_DIR}/{test_obs}.fits.header'
    omm_name = OmmName(file_name=f'{test_obs}.fits', entry=test_file)
    test_file_info = FileInfo(id=omm_name.file_uri)
    test_xml = f'{TESTDATA_DIR}/{test_obs}.xml'
    obs = mc.read_obs_from_file(test_xml)
    headers = data_util.get_local_file_headers(test_file)
    telescope = Telescope(omm_name.file_uri, headers)
    with pytest.raises(mc.CadcException):
        result = telescope.update(obs, omm_name, test_file_info)
        assert result is None, 'should have returned nothing'
def test_update_cal_provenance():
    test_obs = 'C170323_domeflat_K_CALRED'
    test_obs_file = os.path.join(TESTDATA_DIR, f'{test_obs}.expected.xml')
    test_header_file = os.path.join(TESTDATA_DIR, f'{test_obs}.fits.header')
    test_obs = mc.read_obs_from_file(test_obs_file)
    headers = data_util.get_local_file_headers(test_header_file)
    telescope = Telescope(f'ad:OMM/{test_obs}.fits', headers)
    telescope._update_cal_provenance(test_obs)
    assert test_obs is not None, 'no test_obs'
    assert test_obs.members is not None, 'no members'
    assert len(test_obs.members) == 22, 'wrong obs members length'
    test_member = test_obs.members.pop()
    assert test_member.uri.find('caom:OMM/C170323') == 0, 'wrong member value'
    assert test_member.uri.startswith('caom:OMM'), 'wrong member value'
    for ii in test_obs.planes:
        plane = test_obs.planes[ii]
        assert plane.provenance is not None, 'no provenance'
        assert plane.provenance.inputs is not None, 'no provenance inputs'
        assert (len(
            plane.provenance.inputs) == 22), 'wrong provenance inputs length'
        test_plane_input = plane.provenance.inputs.pop()
        assert (test_plane_input.uri.find('caom:OMM/C170323') == 0
                ), 'wrong input value'
        assert test_plane_input.uri.endswith('_CAL'), 'wrong input value'
Пример #4
0
def test_unicode_decode_error():
    test_fqn = join(test_fits2caom2.TESTDATA_DIR, 'time_axes.fits')
    result = data_util.get_local_file_headers(test_fqn)
    assert result is not None, 'expect retry using a different method'