예제 #1
0
    def test_get_time_coordinates(self) -> None:
        db = create_bundle_db_in_memory()
        db.create_tables()
        fits_product_lidvid = "urn:nasa:pds:hst_13012:data_acs_raw:jbz504eoq_raw::2.3"
        os_filepath = path_to_testfile("jbz504eoq_raw.fits")

        populate_database_from_fits_file(db, os_filepath, fits_product_lidvid)

        file_basename = basename(os_filepath)

        card_dicts = db.get_card_dictionaries(fits_product_lidvid,
                                              file_basename)

        nb = get_time_coordinates(
            get_start_stop_times(
                DictLookup("test_get_time_coordinates", card_dicts)))
        doc = xml.dom.getDOMImplementation().createDocument(None, None, None)
        str: bytes = nb(doc).toxml().encode()
        str = pretty_print(str)

        expected = b"""<?xml version="1.0"?>
<Time_Coordinates>
  <start_date_time>2012-09-27T20:23:28Z</start_date_time>
  <stop_date_time>2012-09-27T20:27:58Z</stop_date_time>
</Time_Coordinates>
"""
        self.assertEqual(expected, str)
예제 #2
0
    def test_get_acs_parameters(self) -> None:
        db = create_bundle_db_in_memory()
        db.create_tables()

        def get_card_dicts(suffix: str) -> CARD_SET:
            fits_product_lidvid = (
                f"urn:nasa:pds:hst_13012:data_acs_{suffix}:jbz504eoq_{suffix}::1.0"
            )
            os_filepath = path_to_testfile(f"jbz504eoq_{suffix}.fits")
            populate_database_from_fits_file(db, os_filepath,
                                             fits_product_lidvid)

            file_basename = basename(os_filepath)
            return db.get_card_dictionaries(fits_product_lidvid, file_basename)

        RAWish_lookups = make_hdu_lookups("test_get_acs_parameters:RAW",
                                          get_card_dicts("raw"))
        SHFish_lookup = DictLookup("test_get_acs_parameters:SHF",
                                   get_card_dicts("spt"))
        nb = get_hst_parameters(RAWish_lookups, SHFish_lookup)

        doc = xml.dom.getDOMImplementation().createDocument(None, None, None)
        text: bytes = nb(doc).toxml().encode()
        text = pretty_print(text)

        assert_golden_file_equal(self, "test_hst_parameters.golden.xml", text)
예제 #3
0
    def test_get_default_target(self) -> None:
        fits_product_lidvid = "urn:nasa:pds:hst_13012:data_acs_raw:jbz504eoq_raw::2.3"
        card_dicts = [{
            "DATE-OBS": "2001-01-02",
            "TIME-OBS": "08:20:00",
            "EXPTIME": "1.0"
        }]
        nb = get_time_coordinates(
            get_start_stop_times(
                DictLookup("test_get_default_target", card_dicts)))
        doc = xml.dom.getDOMImplementation().createDocument(None, None, None)
        str: bytes = nb(doc).toxml().encode()
        str = pretty_print(str)
        expected = b"""<?xml version="1.0"?>
<Time_Coordinates>
  <start_date_time>2001-01-02T08:20:00Z</start_date_time>
  <stop_date_time>2001-01-02T08:20:01Z</stop_date_time>
</Time_Coordinates>
"""
        self.assertEqual(expected, str)
예제 #4
0
def test_pretty_print() -> None:
    """Mostly a smoketest to force parsing of Pretty."""
    assert pretty_print(b"<foobar><baz></baz></foobar>") == _PP
예제 #5
0
    def test_get_file_contents(self) -> None:
        db = create_bundle_db_in_memory()
        db.create_tables()

        fits_product_lidvid = "urn:nasa:pds:hst_13012:data_acs_raw:jbz504eoq_raw::2.0"
        os_filepath = path_to_testfile("jbz504eoq_raw.fits")

        populate_database_from_fits_file(db, os_filepath, fits_product_lidvid)

        file_basename = basename(os_filepath)

        card_dicts = db.get_card_dictionaries(fits_product_lidvid,
                                              file_basename)

        fb = get_file_contents(db, card_dicts, "acs", fits_product_lidvid)
        doc = _fragment_wrapper({"frag": fb})
        str: bytes = doc.toxml().encode()
        str = pretty_print(str)

        expected = b"""<?xml version="1.0"?>
<Wrapper>
  <Header>
    <local_identifier>hdu_0</local_identifier>
    <offset unit="byte">0</offset>
    <object_length unit="byte">14400</object_length>
    <parsing_standard_id>FITS 3.0</parsing_standard_id>
    <description>Global FITS Header</description>
  </Header>
  <Header>
    <local_identifier>hdu_1</local_identifier>
    <offset unit="byte">14400</offset>
    <object_length unit="byte">8640</object_length>
    <parsing_standard_id>FITS 3.0</parsing_standard_id>
    <description>FITS Header</description>
  </Header>
  <Array_2D_Image>
    <offset unit="byte">23040</offset>
    <axes>2</axes>
    <axis_index_order>Last Index Fastest</axis_index_order>
    <Element_Array>
      <data_type>SignedMSB2</data_type>
    </Element_Array>
    <Axis_Array>
      <axis_name>Line</axis_name>
      <elements>1024</elements>
      <sequence_number>1</sequence_number>
    </Axis_Array>
    <Axis_Array>
      <axis_name>Sample</axis_name>
      <elements>1024</elements>
      <sequence_number>2</sequence_number>
    </Axis_Array>
  </Array_2D_Image>
  <Header>
    <local_identifier>hdu_2</local_identifier>
    <offset unit="byte">2122560</offset>
    <object_length unit="byte">5760</object_length>
    <parsing_standard_id>FITS 3.0</parsing_standard_id>
    <description>FITS Header</description>
  </Header>
  <Header>
    <local_identifier>hdu_3</local_identifier>
    <offset unit="byte">2128320</offset>
    <object_length unit="byte">5760</object_length>
    <parsing_standard_id>FITS 3.0</parsing_standard_id>
    <description>FITS Header</description>
  </Header>
</Wrapper>
"""
        self.assertEqual(expected, str)