Esempio n. 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)
Esempio n. 2
0
        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)
Esempio n. 3
0
            def make_lidvid(suffix: str) -> Tuple[str, str]:
                collection_type = get_collection_type(suffix=suffix)
                fits_product_lidvid = f"urn:nasa:pds:hst_09059:{collection_type}_acs_{suffix}:j6gp01mkq::1.0"
                self.db.create_fits_product(fits_product_lidvid,
                                            collection_lidvid)

                file_basename = f"j6gp01mkq_{suffix}.fits"
                os_filepath = path_to_testfile(file_basename)
                temp_filepath = os.path.join(mast_dir, file_basename)
                shutil.copyfile(os_filepath, temp_filepath)
                populate_database_from_fits_file(self.db, temp_filepath,
                                                 fits_product_lidvid)
                return (fits_product_lidvid, file_basename)
Esempio n. 4
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)