def get_composite_observation(self):
     composite_observation = \
         observation.CompositeObservation(Caom2TestInstances._collection,
                                          Caom2TestInstances._observation_id,
                                          self.get_algorithm())
     print("Creating test composite observation of version " + str(self.caom_version))
     if self.complete:
         composite_observation.sequence_number = int(10)
         composite_observation.obs_type = "filed"
         composite_observation.intent = observation.ObservationIntentType.SCIENCE
         composite_observation.meta_release = Caom2TestInstances._ivoa_date
         composite_observation.proposal = self.get_proposal()
         composite_observation.target = self.get_target()
         composite_observation.target_position = self.get_target_position()
         if self.caom_version == 21:
             composite_observation.requirements = self.get_requirements()
         composite_observation.telescope = self.get_telescope()
         composite_observation.instrument = self.get_instrument()
         composite_observation.environment = self.get_environment()
         composite_observation.last_modified = common.get_current_ivoa_time()
         if self.caom_version >= 23:
             composite_observation.max_last_modified = common.get_current_ivoa_time()
             composite_observation.meta_checksum = common.ChecksumURI("md5:9882dbbf9cadc221019b712fd402bcbd")
             composite_observation.acc_meta_checksum = common.ChecksumURI("md5:844ce247db0844ad9f721430c80e7a21")
     if self.depth > 1:
         composite_observation.planes.update(self.get_planes())
         composite_observation.members.update(self.get_members())
     return composite_observation
    def get_planes(self):
        planes = collections.OrderedDict()
        _plane = plane.Plane("productID")
        if self.complete:
            _plane.meta_release = Caom2TestInstances._ivoa_date
            _plane.data_release = Caom2TestInstances._ivoa_date
            _plane.data_product_type = plane.DataProductType.IMAGE
            _plane.calibration_level = plane.CalibrationLevel.PRODUCT
            _plane.provenance = self.get_provenance()
            _plane.metrics = self.get_metrics()
            _plane.last_modified = common.get_current_ivoa_time()
            if self.caom_version >= 23:
                _plane.creator_id = "ivo://cadc.nrc.ca?testuser"
                _plane.max_last_modified = common.get_current_ivoa_time()
                _plane.meta_checksum = common.ChecksumURI("md5:9882dbbf9cadc221019b712fd402bcbd")
                _plane.acc_meta_checksum = common.ChecksumURI("md5:844ce247db0844ad9f721430c80e7a21")
            if self.caom_version >= 22:
                _plane.position = self.get_position()
                _plane.energy = self.get_energy()
                _plane.time = self.get_time()
                _plane.polarization = self.get_polarization()
            if self.caom_version == 21:
                _plane.quality = self.get_quality()

        if self.depth > 2:
            for k, v in six.iteritems(self.get_artifacts()):
                _plane.artifacts[k] = v
        planes["productID"] = _plane
        return planes
 def get_chunks(self):
     chunks = caom_util.TypedList(chunk.Chunk, )
     _chunk = chunk.Chunk()
     if self.complete:
         _chunk.product_type = chunk.ProductType.SCIENCE
         _chunk.naxis = 5
         _chunk.observable_axis = 1
         _chunk.position_axis_1 = 1
         _chunk.position_axis_2 = 2
         _chunk.energy_axis = 3
         _chunk.time_axis = 4
         _chunk.polarization_axis = 5
         _chunk.observable = self.get_observable_axis()
         _chunk.position = self.get_spatial_wcs()
         _chunk.energy = self.get_spectral_wcs()
         _chunk.time = self.get_temporal_wcs()
         _chunk.polarization = self.get_polarization_wcs()
         _chunk.last_modified = common.get_current_ivoa_time()
         if self.caom_version >= 23:
             _chunk.max_last_modified = common.get_current_ivoa_time()
             _chunk.meta_checksum = common.ChecksumURI(
                 "md5:9882dbbf9cadc221019b712fd402bcbd")
             _chunk.acc_meta_checksum = common.ChecksumURI(
                 "md5:844ce247db0844ad9f721430c80e7a21")
     chunks.append(_chunk)
     return chunks
 def get_simple_observation(self):
     simple_observation = \
         observation.SimpleObservation(Caom2TestInstances._collection,
                                       Caom2TestInstances._observation_id)
     if self.complete:
         simple_observation.sequence_number = int(5)
         simple_observation.obs_type = "flat"
         simple_observation.intent = observation.ObservationIntentType.CALIBRATION
         simple_observation.meta_release = Caom2TestInstances._ivoa_date
         simple_observation.proposal = self.get_proposal()
         simple_observation.target = self.get_target()
         simple_observation.target_position = self.get_target_position()
         if self.caom_version == 21:
             simple_observation.requirements = self.get_requirements()
         simple_observation.telescope = self.get_telescope()
         simple_observation.instrument = self.get_instrument()
         simple_observation.environment = self.get_environment()
         simple_observation.last_modified = common.get_current_ivoa_time()
         if self.caom_version >= 23:
             simple_observation.max_last_modified = common.get_current_ivoa_time()
             simple_observation.meta_checksum = common.ChecksumURI("md5:9882dbbf9cadc221019b712fd402bcbd")
             simple_observation.acc_meta_checksum = common.ChecksumURI("md5:844ce247db0844ad9f721430c80e7a21")
     if self.depth > 1:
         simple_observation.planes.update(self.get_planes())
     return simple_observation
 def get_simple_observation(self, short_uuid=False):
     simple_observation = \
         observation.SimpleObservation(Caom2TestInstances._collection,
                                       Caom2TestInstances._observation_id)
     if self.complete:
         simple_observation.sequence_number = int(5)
         simple_observation.obs_type = "flat"
         simple_observation.intent =\
             observation.ObservationIntentType.CALIBRATION
         simple_observation.meta_release = Caom2TestInstances._ivoa_date
         simple_observation.proposal = self.get_proposal()
         simple_observation.target = self.get_target()
         simple_observation.target_position = self.get_target_position()
         if self.caom_version == 21:
             simple_observation.requirements = self.get_requirements()
         simple_observation.telescope = self.get_telescope()
         simple_observation.instrument = self.get_instrument()
         simple_observation.environment = self.get_environment()
         simple_observation.last_modified = common.get_current_ivoa_time()
         if self.caom_version >= 23:
             simple_observation.max_last_modified =\
                 common.get_current_ivoa_time()
             simple_observation.meta_checksum = common.ChecksumURI(
                 "md5:9882dbbf9cadc221019b712fd402bcbd")
             simple_observation.acc_meta_checksum = common.ChecksumURI(
                 "md5:844ce247db0844ad9f721430c80e7a21")
     if self.depth > 1:
         simple_observation.planes.update(self.get_planes())
     if self.caom_version == 20 or short_uuid:
         fix_ids(simple_observation)
     return simple_observation
 def get_chunks(self):
     chunks = caom_util.TypedList(chunk.Chunk, )
     _chunk = chunk.Chunk()
     if self.complete:
         _chunk.product_type = chunk.ProductType.SCIENCE
         _chunk.naxis = 5
         _chunk.observable_axis = 1
         _chunk.position_axis_1 = 1
         _chunk.position_axis_2 = 2
         _chunk.energy_axis = 3
         _chunk.time_axis = 4
         _chunk.polarization_axis = 5
         _chunk.observable = self.get_observable_axis()
         _chunk.position = self.get_spatial_wcs()
         _chunk.energy = self.get_spectral_wcs()
         _chunk.time = self.get_temporal_wcs()
         _chunk.polarization = self.get_polarization_wcs()
         _chunk.last_modified = common.get_current_ivoa_time()
         if self.caom_version >= 23:
             _chunk.max_last_modified = common.get_current_ivoa_time()
             _chunk.meta_checksum = common.ChecksumURI(
                 "md5:9882dbbf9cadc221019b712fd402bcbd")
             _chunk.acc_meta_checksum = common.ChecksumURI(
                 "md5:844ce247db0844ad9f721430c80e7a21")
     chunks.append(_chunk)
     return chunks
    def get_planes(self):
        planes = collections.OrderedDict()
        if self.caom_version < 22:
            shapes = ['']
        elif self.caom_version >= 23:
            shapes = ['polygon', 'circle']
        else:
            shapes = ['polygon']

        for s in shapes:
            prod_id = "productID{}".format(s)
            _plane = plane.Plane(prod_id)
            if self.complete:
                _plane.meta_release = Caom2TestInstances._ivoa_date
                _plane.data_release = Caom2TestInstances._ivoa_date
                _plane.data_product_type = plane.DataProductType.IMAGE
                _plane.calibration_level = plane.CalibrationLevel.PRODUCT
                _plane.provenance = self.get_provenance()
                _plane.metrics = self.get_metrics()
                _plane.last_modified = common.get_current_ivoa_time()
                if self.caom_version >= 23:
                    _plane.creator_id = "ivo://cadc.nrc.ca?testuser"
                    _plane.max_last_modified = common.get_current_ivoa_time()
                    _plane.meta_checksum = common.ChecksumURI(
                        "md5:9882dbbf9cadc221019b712fd402bcbd")
                    _plane.acc_meta_checksum = common.ChecksumURI(
                        "md5:844ce247db0844ad9f721430c80e7a21")
                if s == 'polygon':
                    _plane.position = self.get_poly_position()
                if s == 'circle':
                    _plane.position = self.get_circle_position()
                _plane.energy = self.get_energy()
                _plane.time = self.get_time()
                _plane.polarization = self.get_polarization()
                if self.caom_version >= 24:
                    _plane.custom_axis = self.get_custom()
                    _plane.meta_read_groups.add('ivo://cadc.nrc.ca/groups?A')
                    _plane.meta_read_groups.add('ivo://cadc.nrc.ca/groups?D')
                    _plane.data_read_groups.add('ivo://cadc.nrc.ca/groups?B')
                    _plane.data_read_groups.add('ivo://cadc.nrc.ca/groups?C')

            if self.depth > 2:
                for k, v in six.iteritems(self.get_artifacts()):
                    _plane.artifacts[k] = v
            planes[prod_id] = _plane
        return planes
 def get_artifacts(self):
     artifacts = collections.OrderedDict()
     _artifact = artifact.Artifact("ad:foo/bar1",
                                   chunk.ProductType.SCIENCE,
                                   artifact.ReleaseType.META)
     if self.complete:
         _artifact.content_type = "application/fits"
         _artifact.content_length = int(12345)
         _artifact.last_modified = common.get_current_ivoa_time()
         if self.caom_version >= 23:
             _artifact.max_last_modified = common.get_current_ivoa_time()
             _artifact.meta_checksum = common.ChecksumURI("md5:9882dbbf9cadc221019b712fd402bcbd")
             _artifact.acc_meta_checksum = common.ChecksumURI("md5:844ce247db0844ad9f721430c80e7a21")
     if self.depth > 3:
         for k, v in six.iteritems(self.get_parts()):
             _artifact.parts[k] = v
     artifacts["ad:foo/bar1"] = _artifact
     return artifacts
    def get_planes(self):
        planes = collections.OrderedDict()
        if self.caom_version < 22:
            shapes = ['']
        elif self.caom_version >= 23:
            shapes = ['polygon', 'circle']
        else:
            shapes = ['polygon']

        for s in shapes:
            prod_id = "productID{}".format(s)
            _plane = plane.Plane(prod_id)
            if self.complete:
                _plane.meta_release = Caom2TestInstances._ivoa_date
                _plane.data_release = Caom2TestInstances._ivoa_date
                _plane.data_product_type = plane.DataProductType.IMAGE
                _plane.calibration_level = plane.CalibrationLevel.PRODUCT
                _plane.provenance = self.get_provenance()
                _plane.metrics = self.get_metrics()
                _plane.last_modified = common.get_current_ivoa_time()
                if self.caom_version >= 23:
                    _plane.creator_id = "ivo://cadc.nrc.ca?testuser"
                    _plane.max_last_modified = common.get_current_ivoa_time()
                    _plane.meta_checksum = common.ChecksumURI(
                        "md5:9882dbbf9cadc221019b712fd402bcbd")
                    _plane.acc_meta_checksum = common.ChecksumURI(
                        "md5:844ce247db0844ad9f721430c80e7a21")
                if s == 'polygon':
                    _plane.position = self.get_poly_position()
                if s == 'circle':
                    _plane.position = self.get_circle_position()
                if self.caom_version >= 22:
                    _plane.energy = self.get_energy()
                    _plane.time = self.get_time()
                    _plane.polarization = self.get_polarization()
                if self.caom_version == 21:
                    _plane.quality = self.get_quality()

            if self.depth > 2:
                for k, v in six.iteritems(self.get_artifacts()):
                    _plane.artifacts[k] = v
            planes[prod_id] = _plane
        return planes
 def get_artifacts(self):
     artifacts = collections.OrderedDict()
     _artifact = artifact.Artifact("ad:foo/bar1",
                                   chunk.ProductType.SCIENCE,
                                   artifact.ReleaseType.META)
     if self.complete:
         _artifact.content_type = "application/fits"
         _artifact.content_length = int(12345)
         _artifact.last_modified = common.get_current_ivoa_time()
         if self.caom_version >= 23:
             _artifact.max_last_modified = common.get_current_ivoa_time()
             _artifact.meta_checksum = common.ChecksumURI(
                 "md5:9882dbbf9cadc221019b712fd402bcbd")
             _artifact.acc_meta_checksum = common.ChecksumURI(
                 "md5:844ce247db0844ad9f721430c80e7a21")
     if self.depth > 3:
         for k, v in six.iteritems(self.get_parts()):
             _artifact.parts[k] = v
     artifacts["ad:foo/bar1"] = _artifact
     return artifacts
 def get_composite_observation(self, short_uuid=False):
     composite_observation = \
         observation.CompositeObservation(
             Caom2TestInstances._collection,
             Caom2TestInstances._observation_id,
             self.get_algorithm())
     print("Creating test composite observation of version " + str(
         self.caom_version))
     if self.complete:
         composite_observation.sequence_number = int(10)
         composite_observation.obs_type = "filed"
         composite_observation.intent =\
             observation.ObservationIntentType.SCIENCE
         composite_observation.meta_release = Caom2TestInstances._ivoa_date
         composite_observation.proposal = self.get_proposal()
         composite_observation.target = self.get_target()
         composite_observation.target_position = self.get_target_position()
         if self.caom_version == 21:
             composite_observation.requirements = self.get_requirements()
         composite_observation.telescope = self.get_telescope()
         composite_observation.instrument = self.get_instrument()
         composite_observation.environment = self.get_environment()
         composite_observation.last_modified =\
             common.get_current_ivoa_time()
         if self.caom_version >= 23:
             composite_observation.max_last_modified = \
                 common.get_current_ivoa_time()
             composite_observation.meta_checksum = common.ChecksumURI(
                 "md5:9882dbbf9cadc221019b712fd402bcbd")
             composite_observation.acc_meta_checksum = common.ChecksumURI(
                 "md5:844ce247db0844ad9f721430c80e7a21")
     if self.depth > 1:
         composite_observation.planes.update(self.get_planes())
         composite_observation.members.update(self.get_members())
     if self.caom_version == 20 or short_uuid:
         # fix all entity ids to be 64 bit longs
         fix_ids(composite_observation)
     return composite_observation
 def get_derived_observation(self, short_uuid=False):
     derived_observation = \
         observation.DerivedObservation(
             Caom2TestInstances._collection,
             Caom2TestInstances._observation_id,
             self.get_algorithm())
     print("Creating test composite observation of version " +
           str(self.caom_version))
     if self.complete:
         derived_observation.sequence_number = int(10)
         derived_observation.obs_type = "filed"
         derived_observation.intent =\
             observation.ObservationIntentType.SCIENCE
         derived_observation.meta_release = Caom2TestInstances._ivoa_date
         derived_observation.proposal = self.get_proposal()
         derived_observation.target = self.get_target()
         derived_observation.target_position = self.get_target_position()
         derived_observation.telescope = self.get_telescope()
         derived_observation.instrument = self.get_instrument()
         derived_observation.environment = self.get_environment()
         derived_observation.last_modified =\
             common.get_current_ivoa_time()
         derived_observation.max_last_modified = \
             common.get_current_ivoa_time()
         derived_observation.meta_checksum = common.ChecksumURI(
             "md5:9882dbbf9cadc221019b712fd402bcbd")
         derived_observation.acc_meta_checksum = common.ChecksumURI(
             "md5:844ce247db0844ad9f721430c80e7a21")
         derived_observation.meta_read_groups.add(
             "ivo://cadc.nrc.ca/groups?A")
         derived_observation.meta_read_groups.add(
             "ivo://cadc.nrc.ca/groups?B")
     if self.depth > 1:
         derived_observation.planes.update(self.get_planes())
         derived_observation.members.update(self.get_members())
     return derived_observation