Ejemplo n.º 1
0
 def test_unspecifiedprocess(self):
     mysip = create_basicdoc()
     print("===\nAdding unspecified process:\n")
     print(
         mysip.add_unspecifiedprocess(observingmode="Interferometer",
                                      description="unspecified",
                                      process_map=create_processmap()))
     mysip.save_to_file(TMPFILE_PATH)
     self.assertTrue(validator.validate(TMPFILE_PATH))
Ejemplo n.º 2
0
 def test_add_sip(self):
     # create example doc with mandatory attributes
     mysip = create_basicdoc()
     with open(RELATEDSIP) as f:
         xml = f.read()
     sip = siplib.Sip.from_xml(xml)
     mysip.add_related_dataproduct_with_history(sip)
     mysip.save_to_file(TMPFILE_PATH)
     self.assertTrue(validator.validate(TMPFILE_PATH))
Ejemplo n.º 3
0
    def test_parset(self):
        mysip = create_basicdoc()
        print("===\nAdding parset:\n")
        print(
            mysip.add_parset(identifier=siplib.Identifier("test"),
                             contents="blabla"))

        mysip.save_to_file(TMPFILE_PATH)
        self.assertTrue(validator.validate(TMPFILE_PATH))
Ejemplo n.º 4
0
    def test_dataproducts(self):
        mysip = create_basicdoc()
        print("===\nAdding related generic dataproduct:\n")
        with open(FEEDBACK_PATH) as f:
            text = f.readlines()
            fb = feedback.Feedback(text)
        pipe_label = siplib.Identifier('test')
        dataproducts = fb.get_dataproducts(prefix="test.prefix",
                                           process_identifier=pipe_label)
        for dp in dataproducts:
            print("...adding:", dp)
            mysip.add_related_dataproduct(dp)

        mysip.save_to_file(TMPFILE_PATH)
        self.assertTrue(validator.validate(TMPFILE_PATH))
Ejemplo n.º 5
0
 def test_basic_doc(self):
     # create example doc with mandatory attributes
     print("===\nCreating basic document:\n")
     mysip = create_basicdoc()
     mysip.save_to_file(TMPFILE_PATH)
     self.assertTrue(validator.validate(TMPFILE_PATH))
Ejemplo n.º 6
0
    def test_pipelines(self):
        mysip = create_basicdoc()
        print("===\nAdding simple pipelinerun:\n")
        print(
            mysip.add_pipelinerun(siplib.SimplePipeline(create_pipelinemap())))

        print("===\nAdding generic pipelinerun:\n")
        print(
            mysip.add_pipelinerun(siplib.GenericPipeline(
                create_pipelinemap())))

        print("===\nAdding cosmic ray pipelinerun:\n")
        print(
            mysip.add_pipelinerun(
                siplib.CosmicRayPipeline(create_pipelinemap())))

        print("===\nAdding long baseline pipelinerun:\n")
        print(
            mysip.add_pipelinerun(
                siplib.LongBaselinePipeline(create_pipelinemap(),
                                            subbandspersubbandgroup=5,
                                            subbandgroupspermS=5)))

        print("===\nAdding imaging pipelinerun:\n")
        print(
            mysip.add_pipelinerun(
                siplib.ImagingPipeline(
                    create_pipelinemap(),
                    imagerintegrationtime=10,
                    imagerintegrationtime_unit="ms",
                    numberofmajorcycles=5,
                    numberofinstrumentmodels=5,
                    numberofcorrelateddataproducts=1,
                    numberofskyimages=1,
                )))

        print("===\nAdding calibration pipelinerun:\n")
        print(
            mysip.add_pipelinerun(
                siplib.CalibrationPipeline(create_pipelinemap(),
                                           skymodeldatabase="db",
                                           numberofinstrumentmodels=1,
                                           numberofcorrelateddataproducts=1,
                                           frequencyintegrationstep=1,
                                           timeintegrationstep=1,
                                           flagautocorrelations=True,
                                           demixing=False)))

        print("===\nAdding averaging pipelinerun:\n")
        print(
            mysip.add_pipelinerun(
                siplib.AveragingPipeline(create_pipelinemap(),
                                         numberofcorrelateddataproducts=1,
                                         frequencyintegrationstep=1,
                                         timeintegrationstep=1,
                                         flagautocorrelations=True,
                                         demixing=False)))

        print("===\nAdding pulsar pipelinerun:\n")
        print(
            mysip.add_pipelinerun(
                siplib.PulsarPipeline(
                    create_pipelinemap(),
                    pulsarselection=
                    "Pulsars in observation specs, file and brightest in SAP and TAB",
                    pulsars=["J1234+67"],
                    dosinglepulseanalysis=False,
                    convertRawTo8bit=True,
                    subintegrationlength=10,
                    subintegrationlength_unit='ns',
                    skiprfiexcision=False,
                    skipdatafolding=False,
                    skipoptimizepulsarprofile=True,
                    skipconvertrawintofoldedpsrfits=False,
                    runrotationalradiotransientsanalysis=True,
                    skipdynamicspectrum=False,
                    skipprefold=True)))

        mysip.save_to_file(TMPFILE_PATH)
        self.assertTrue(validator.validate(TMPFILE_PATH))
Ejemplo n.º 7
0
    def test_observation(self):
        mysip = create_basicdoc()
        # add optional observation item
        print("===\nAdding observation:\n")
        print(
            mysip.add_observation(
                siplib.Observation(
                    observingmode="Interferometer",
                    instrumentfilter="10-70 MHz",
                    clock_frequency='160',
                    clock_frequencyunit="MHz",
                    stationselection="Core",
                    antennaset="HBA Zero",
                    timesystem="UTC",
                    stations=[
                        siplib.Station.preconfigured("RS106", ["LBA"]),
                        siplib.Station.preconfigured("DE609", ["HBA"])
                    ],
                    numberofstations=5,
                    numberofsubarraypointings=5,
                    numberoftbbevents=5,
                    numberofcorrelateddataproducts=5,
                    numberofbeamformeddataproducts=5,
                    numberofbitspersample=5,
                    process_map=create_processmap(),
                    observationdescription="description",
                    channelwidth_frequency=160,
                    channelwidth_frequencyunit="MHz",
                    channelspersubband=5,
                    subarraypointings=[
                        siplib.SubArrayPointing(
                            pointing=siplib.PointingAltAz(
                                az_angle=20,
                                az_angleunit="degrees",
                                alt_angle=30,
                                alt_angleunit="degrees",
                                equinox="SUN"),
                            beamnumber=5,
                            identifier=point_id,
                            measurementtype="All Sky",
                            targetname="Sun",
                            starttime="1980-03-23T10:20:15",
                            duration="P6Y3M10DT15H",
                            numberofprocessing=1,
                            numberofcorrelateddataproducts=2,
                            numberofbeamformeddataproducts=1,
                            relations=[
                                siplib.ProcessRelation(
                                    identifier=siplib.Identifier("test"))
                            ],
                            correlatorprocessing=siplib.CorrelatorProcessing(
                                integrationinterval=0.5,
                                integrationinterval_unit="ns",
                                channelwidth_frequency=160,
                                channelwidth_frequencyunit="MHz"),
                            coherentstokesprocessing=siplib.
                            CoherentStokesProcessing(
                                rawsamplingtime=20,
                                rawsamplingtime_unit="ns",
                                timesamplingdownfactor=2,
                                samplingtime=10,
                                samplingtime_unit="ns",
                                stokes=["XX"],
                                numberofstations=1,
                                stations=[
                                    siplib.Station.preconfigured(
                                        "CS002", ["HBA0", "HBA1"])
                                ],
                                frequencydownsamplingfactor=2,
                                numberofcollapsedchannels=2,
                                channelwidth_frequency=160,
                                channelwidth_frequencyunit="MHz",
                                channelspersubband=122),
                            incoherentstokesprocessing=siplib.
                            IncoherentStokesProcessing(
                                rawsamplingtime=20,
                                rawsamplingtime_unit="ns",
                                timesamplingdownfactor=2,
                                samplingtime=10,
                                samplingtime_unit="ns",
                                stokes=["XX"],
                                numberofstations=1,
                                stations=[
                                    siplib.Station.preconfigured(
                                        "CS003", ["HBA0", "HBA1"])
                                ],
                                frequencydownsamplingfactor=2,
                                numberofcollapsedchannels=2,
                                channelwidth_frequency=160,
                                channelwidth_frequencyunit="MHz",
                                channelspersubband=122),
                            flyseyeprocessing=siplib.FlysEyeProcessing(
                                rawsamplingtime=10,
                                rawsamplingtime_unit="ms",
                                timesamplingdownfactor=2,
                                samplingtime=2,
                                samplingtime_unit="ms",
                                stokes=["I"],
                            ),
                            nonstandardprocessing=siplib.NonStandardProcessing(
                                channelwidth_frequency=160,
                                channelwidth_frequencyunit="MHz",
                                channelspersubband=122))
                    ],
                    transientbufferboardevents=["event1", "event2"])))

        mysip.save_to_file(TMPFILE_PATH)
        self.assertTrue(validator.validate(TMPFILE_PATH))
Ejemplo n.º 8
0
    def test_dataproducts(self):
        mysip = create_basicdoc()
        print("===\nAdding related generic dataproduct:\n")
        # add optional dataproduct item
        print(
            mysip.add_related_dataproduct(
                siplib.GenericDataProduct(create_dataproductmap())))

        # add optional dataproduct item
        print("===\nAdding related pulp summary dataproduct:\n")
        print(
            mysip.add_related_dataproduct(
                siplib.PulpSummaryDataProduct(
                    create_dataproductmap(),
                    filecontent=["content_a", "content_b"],
                    datatype="CoherentStokes")))

        # add optional dataproduct item
        print("===\nAdding related pulp dataproduct:\n")
        print(
            mysip.add_related_dataproduct(
                siplib.PulpDataProduct(
                    create_dataproductmap(),
                    filecontent=["content_a", "content_b"],
                    datatype="CoherentStokes",
                    arraybeam=siplib.SimpleArrayBeam(
                        siplib.ArrayBeamMap(
                            subarraypointing_identifier=point_id,
                            beamnumber=4,
                            dispersionmeasure=16,
                            numberofsubbands=3,
                            stationsubbands=[1, 2, 3],
                            samplingtime=3,
                            samplingtimeunit="ms",
                            centralfrequencies="",
                            centralfrequencies_unit="MHz",
                            channelwidth_frequency=160,
                            channelwidth_frequencyunit="MHz",
                            channelspersubband=5,
                            stokes=["I", "Q"])))))

        # add optional dataproduct item
        print("===\nAdding related beamformed dataproduct:\n")
        print(
            mysip.add_related_dataproduct(
                siplib.BeamFormedDataProduct(
                    create_dataproductmap(),
                    beams=[
                        siplib.FlysEyeBeam(
                            arraybeam_map=siplib.ArrayBeamMap(
                                subarraypointing_identifier=point_id,
                                beamnumber=4,
                                dispersionmeasure=16,
                                numberofsubbands=3,
                                stationsubbands=[1, 2, 3],
                                samplingtime=3,
                                samplingtimeunit="ms",
                                centralfrequencies="",
                                centralfrequencies_unit="MHz",
                                channelwidth_frequency=160,
                                channelwidth_frequencyunit="MHz",
                                channelspersubband=5,
                                stokes=["I", "Q"]),
                            station=siplib.Station.preconfigured(
                                "CS001", ["HBA0", "HBA1"]))
                    ])))

        # add optional dataproduct item
        print("===\nAdding related sky image dataproduct:\n")
        print(
            mysip.add_related_dataproduct(
                siplib.SkyImageDataProduct(
                    create_dataproductmap(),
                    numberofaxes=2,
                    coordinates=[
                        siplib.SpectralCoordinate(quantity_type="Frequency",
                                                  quantity_value=20.0,
                                                  axis=siplib.LinearAxis(
                                                      number=5,
                                                      name="bla",
                                                      units="parsec",
                                                      length=5,
                                                      increment=5,
                                                      referencepixel=7.5,
                                                      referencevalue=7.4)),
                        siplib.SpectralCoordinate(quantity_type="Frequency",
                                                  quantity_value=20.0,
                                                  axis=siplib.TabularAxis(
                                                      number=5,
                                                      name="bla",
                                                      units="parsec",
                                                      length=5,
                                                  )),
                        siplib.DirectionCoordinate(
                            linearaxis_a=siplib.LinearAxis(number=5,
                                                           name="bla",
                                                           units="parsec",
                                                           length=5,
                                                           increment=5,
                                                           referencepixel=7.5,
                                                           referencevalue=7.4),
                            linearaxis_b=siplib.LinearAxis(number=5,
                                                           name="bla",
                                                           units="parsec",
                                                           length=5,
                                                           increment=5,
                                                           referencepixel=7.5,
                                                           referencevalue=7.4),
                            pc0_0=0.0,
                            pc0_1=0.1,
                            pc1_0=1.0,
                            pc1_1=1.1,
                            equinox="SUN",
                            radecsystem="ICRS",
                            projection="rear",
                            projectionparameters=[1.0, 1.0, 1.0],
                            longitudepole_angle=1.0,
                            longitudepole_angleunit="degrees",
                            latitudepole_angle=2.0,
                            latitudepole_angleunit="degrees",
                        ),
                        siplib.PolarizationCoordinate(
                            tabularaxis=siplib.TabularAxis(
                                number=5,
                                name="bla",
                                units="parsec",
                                length=5,
                            ),
                            polarizations=["I", "YY", "XX", "Q"]),
                        siplib.TimeCoordinate(
                            equinox="SUN",
                            axis=siplib.TabularAxis(
                                number=5,
                                name="timetabular",
                                units="parsec",
                                length=5,
                            ),
                        )
                    ],
                    locationframe="GEOCENTER",
                    timeframe="timeframe",
                    observationpointing=siplib.PointingRaDec(
                        ra_angle=1.0,
                        ra_angleunit="degrees",
                        dec_angle=42.0,
                        dec_angleunit="degrees",
                        equinox="SUN"),
                    restoringbeammajor_angle=1.0,
                    restoringbeammajor_angleunit="degrees",
                    restoringbeamminor_angle=2.0,
                    restoringbeamminor_angleunit="degrees",
                    rmsnoise=1.0)))

        # add optional dataproduct item
        print("===\nAdded related correlated dataproduct:\n")
        print(
            mysip.add_related_dataproduct(
                siplib.CorrelatedDataProduct(
                    create_dataproductmap(),
                    subarraypointing_identifier=siplib.Identifier("test"),
                    subband="1",
                    starttime="1980-03-23T10:20:15",
                    duration="P6Y3M10DT15H",
                    integrationinterval=10,
                    integrationintervalunit="ms",
                    central_frequency=160,
                    central_frequencyunit="MHz",
                    channelwidth_frequency=200,
                    channelwidth_frequencyunit="MHz",
                    channelspersubband=122,
                    stationsubband=2,
                )))

        # add optional dataproduct item
        print("===\nAdding related pixelmap dataproduct:\n")
        print(
            mysip.add_related_dataproduct(
                siplib.PixelMapDataProduct(create_dataproductmap(),
                                           numberofaxes=5,
                                           coordinates=[
                                               siplib.SpectralCoordinate(
                                                   quantity_type="Frequency",
                                                   quantity_value=20.0,
                                                   axis=siplib.LinearAxis(
                                                       number=5,
                                                       name="bla",
                                                       units="parsec",
                                                       length=5,
                                                       increment=5,
                                                       referencepixel=7.5,
                                                       referencevalue=7.4))
                                           ])))

        # add optional dataproduct item
        print(
            "===\nAdding related pixelmap dataproduct using predefined constants:\n"
        )
        print(
            mysip.add_related_dataproduct(
                siplib.SkyImageDataProduct(
                    create_dataproductmap(),
                    numberofaxes=2,
                    coordinates=[
                        siplib.SpectralCoordinate(
                            quantity_type=constants.
                            SPECTRALQUANTITYTYPE_VELOCITYAPPRADIAL,
                            quantity_value=20.0,
                            axis=siplib.LinearAxis(number=5,
                                                   name="bla",
                                                   units="unit",
                                                   length=5,
                                                   increment=5,
                                                   referencepixel=7.5,
                                                   referencevalue=7.4)),
                        siplib.DirectionCoordinate(
                            linearaxis_a=siplib.LinearAxis(number=5,
                                                           name="bla",
                                                           units="unit",
                                                           length=5,
                                                           increment=5,
                                                           referencepixel=7.5,
                                                           referencevalue=7.4),
                            linearaxis_b=siplib.LinearAxis(number=5,
                                                           name="blb",
                                                           units="unit",
                                                           length=5,
                                                           increment=5,
                                                           referencepixel=7.5,
                                                           referencevalue=7.4),
                            pc0_0=0.0,
                            pc0_1=0.1,
                            pc1_0=1.0,
                            pc1_1=1.1,
                            equinox=constants.EQUINOXTYPE_JUPITER,
                            radecsystem=constants.RADECSYSTEM_FK4_NO_E,
                            projection="rear",
                            projectionparameters=[1.0, 1.0, 1.0],
                            longitudepole_angle=1.0,
                            longitudepole_angleunit=constants.
                            ANGLEUNIT_RADIANS,
                            latitudepole_angle=2.0,
                            latitudepole_angleunit=constants.ANGLEUNIT_ARCSEC,
                        ),
                        siplib.PolarizationCoordinate(
                            tabularaxis=siplib.TabularAxis(
                                number=5,
                                name="bla",
                                units="someunit",
                                length=5,
                            ),
                            polarizations=[
                                constants.POLARIZATIONTYPE_LR,
                                constants.POLARIZATIONTYPE_XRE
                            ]),
                    ],
                    locationframe=constants.LOCATIONFRAME_LOCAL_GROUP,
                    timeframe="timeframe",
                    observationpointing=siplib.PointingRaDec(
                        ra_angle=1.0,
                        ra_angleunit=constants.ANGLEUNIT_DEGREES,
                        dec_angle=42.0,
                        dec_angleunit=constants.ANGLEUNIT_DEGREES,
                        equinox=constants.EQUINOXTYPE_B1950),
                    restoringbeammajor_angle=1.0,
                    restoringbeammajor_angleunit=constants.ANGLEUNIT_DEGREES,
                    restoringbeamminor_angle=2.0,
                    restoringbeamminor_angleunit=constants.ANGLEUNIT_DEGREES,
                    rmsnoise=1.0)))
        mysip.save_to_file(TMPFILE_PATH)
        self.assertTrue(validator.validate(TMPFILE_PATH))
Ejemplo n.º 9
0
 def test_validate(self):
     self.assertTrue(validator.validate(VALIDFILE_PATH))
     self.assertTrue(validator.check_consistency(VALIDFILE_PATH))
     self.assertTrue(validator.main(VALIDFILE_PATH))