Skip to content
Snippets Groups Projects
Commit 9747e2f6 authored by Jörn Künsemöller's avatar Jörn Künsemöller
Browse files

Task #9091 - Tied up some loose ends. Functionally complete except some...

Task #9091 - Tied up some loose ends. Functionally complete except some PipelineRuns that are still missing.
parent d9d7a94e
No related branches found
No related tags found
No related merge requests found
...@@ -6,14 +6,14 @@ ...@@ -6,14 +6,14 @@
# to determine the mandatory and optional elements to create a valid SIP document. This module is designed to # to determine the mandatory and optional elements to create a valid SIP document. This module is designed to
# provide easy-to-use functions that bridges this shortcoming of the Pyxb API. # provide easy-to-use functions that bridges this shortcoming of the Pyxb API.
# #
# Usage: Import module. Create an instance of Sip. Add elements through the Sip.add_X functions. # Usage: Import module. Create an instance of Sip.
# Many of these functions require instances of other classes of the module. # Add elements through the Sip.add_X functions. Many require instances of other classes of the module.
# # call getprettyxml() and e.g. save to disk.
# #
# Note on validation: From construction through every addition, the SIP should remain valid (or throw an error # Note on validation: From construction through every addition, the SIP should remain valid (or throw an error
# that clearly points out where e.g. a given value does not meet the restrictions of the SIP schema. # that clearly points out where e.g. a given value does not meet the restrictions of the SIP schema.
# #
# Note on code structure: This has to be seen as a compromise between elegant and maintainable code with well # Note on code structure: This has to be seen as a compromise between elegant and maintainable code with well-
# structured inheritance close to the schema definition on the one hand, and something more straightforward to use, # structured inheritance close to the schema definition on the one hand, and something more straightforward to use,
# with flatter hierarchies on the other hand. # with flatter hierarchies on the other hand.
# #
...@@ -22,11 +22,12 @@ ...@@ -22,11 +22,12 @@
# a supertype, and indeed is solved like this in the pyxb code. However, this then requires the use of an argument # a supertype, and indeed is solved like this in the pyxb code. However, this then requires the use of an argument
# list pointer, which hides the list of required and optional arguments from the user. Alternatively, all arguments # list pointer, which hides the list of required and optional arguments from the user. Alternatively, all arguments
# have to be mapped in all constructors repeatedly, creating lots of boilerplate code. This is the nicest approach # have to be mapped in all constructors repeatedly, creating lots of boilerplate code. This is the nicest approach
# I could think of that keeps the whole thing reasonably maintainable. # I could think of that keeps the whole thing reasonably maintainable AND usable.
import ltasip import ltasip
import pyxb import pyxb
import os.path
VERSION = "SIPlib 0.1" VERSION = "SIPlib 0.1"
...@@ -38,6 +39,15 @@ VERSION = "SIPlib 0.1" ...@@ -38,6 +39,15 @@ VERSION = "SIPlib 0.1"
# Probably create a Station class for this # Probably create a Station class for this
# We should prepare a dictionary with all present # We should prepare a dictionary with all present
# todo: create docstrings for everything.
# specify types and explain purpose of the field (-> ask someone with more astronomical background)
# todo: check what fields can be implicitely set
# (e.g. parameter type in dataproduct may be derived from the specific dataproduct class that is used)
# Some parameters may also be filled with a reasonable default value. Right now, usually only optional values
# as per schema definition are optional parameters.
# =============================== # ===============================
# Station definitions: # Station definitions:
...@@ -62,15 +72,13 @@ STATIONS = dict(stationA=stationA, ...@@ -62,15 +72,13 @@ STATIONS = dict(stationA=stationA,
stationB=stationB) stationB=stationB)
# #############################################################################################
######################################### end station definitions
# ============== # ==============
# Processes: # Processes:
class ProcessMap(): class ProcessMap():
#todo: relations
def __init__(self, def __init__(self,
strategyname, strategyname,
strategydescription, strategydescription,
...@@ -80,16 +88,17 @@ class ProcessMap(): ...@@ -80,16 +88,17 @@ class ProcessMap():
observation_id, observation_id,
process_source, process_source,
process_id, process_id,
relations,
parset_source=None, parset_source=None,
parset_id=None, parset_id=None,
): ):
__relations=ltasip.ProcessRelations()
for rel in relations:
__relations.append(rel.get_pyxb_processrelation())
self.process_map = dict(processIdentifier=ltasip.IdentifierType(source=process_source, identifier=process_id), self.process_map = dict(processIdentifier=ltasip.IdentifierType(source=process_source, identifier=process_id),
observationId=ltasip.IdentifierType(source=observation_source, identifier=observation_id), observationId=ltasip.IdentifierType(source=observation_source, identifier=observation_id),
relations=ltasip.ProcessRelations().append( relations=__relations,
ltasip.ProcessRelation(relationType=ltasip.ProcessRelationType("GroupID"),
identifier=ltasip.IdentifierType(source="somesource",
identifier="relationID"))),
strategyName=strategyname, strategyDescription=strategydescription, startTime=starttime, strategyName=strategyname, strategyDescription=strategydescription, startTime=starttime,
duration=duration) duration=duration)
...@@ -99,6 +108,25 @@ class ProcessMap(): ...@@ -99,6 +108,25 @@ class ProcessMap():
def get_dict(self): def get_dict(self):
return self.process_map return self.process_map
class ProcessRelation():
def __init__(self,
identifier_source,
identifier,
name=None,
type="GroupID"
):
self.__pyxb_processrelation=ltasip.ProcessRelation(
relationType=ltasip.ProcessRelationType(type),
identifier=ltasip.IdentifierType(
source=identifier_source,
identifier=identifier,
name=name)
)
def get_pyxb_processrelation(self):
return self.__pyxb_processrelation
class SimpleProcess(): class SimpleProcess():
def __init__(self, process_map): def __init__(self, process_map):
...@@ -115,11 +143,83 @@ class PipelineMap(): ...@@ -115,11 +143,83 @@ class PipelineMap():
def __init__(self, def __init__(self,
name, name,
version, version,
sourcedata, #= type="DataSources"/> sourcedata_source,
sourcedata_identifiers,
process_map process_map
): ):
pass
__sourcedata=ltasip.DataSources()
for id in sourcedata_identifiers:
__sourcedata.append(ltasip.IdentifierType(identifier=id, source=sourcedata_source))
self.pipeline_map=dict(
pipelineName=name,
pipelineVersion=version,
sourceData=__sourcedata
)
self.pipeline_map.update(process_map.get_dict())
def get_dict(self):
return self.pipeline_map
class SimplePipeline():
def __init__(self, pipeline_map):
self.__pyxb_pipeline=ltasip.PipelineRun(**pipeline_map.get_dict())
def get_pyxb_pipeline(self):
return self.__pyxb_pipeline
class ImagingPipeline():
#todo
def get_pyxb_pipeline(self):
return self.__pyxb_pipeline
class CalibrationPipeline():
#todo #todo
def get_pyxb_pipeline(self):
return self.__pyxb_pipeline
class AveragingPipeline():
#todo
def get_pyxb_pipeline(self):
return self.__pyxb_pipeline
class PulsarPipeline():
#todo
def get_pyxb_pipeline(self):
return self.__pyxb_pipeline
class CosmicRayPipeline():
def __init__(self, pipeline_map):
self.__pyxb_pipeline=ltasip.CosmicRayPipeline(**pipeline_map.get_dict())
def get_pyxb_pipeline(self):
return self.__pyxb_pipeline
class LongBaselinePipeline():
def __init__(self,
pipeline_map,
subbandspersubbandgroup,
subbandgroupspermS
):
self.__pyxb_pipeline=ltasip.LongBaselinePipeline(
subbandsPerSubbandGroup=subbandspersubbandgroup,
subbandGroupsPerMS=subbandgroupspermS,
**pipeline_map.get_dict())
def get_pyxb_pipeline(self):
return self.__pyxb_pipeline
class GenericPipeline():
def __init__(self, pipeline_map):
self.__pyxb_pipeline=ltasip.GenericPipeline(**pipeline_map.get_dict())
def get_pyxb_pipeline(self):
return self.__pyxb_pipeline
# ========== # ==========
...@@ -191,7 +291,7 @@ class PixelMapDataProduct(): ...@@ -191,7 +291,7 @@ class PixelMapDataProduct():
self.__pyxb_dataproduct = ltasip.PixelMapDataProduct( self.__pyxb_dataproduct = ltasip.PixelMapDataProduct(
numberOfAxes=numberofaxes, numberOfAxes=numberofaxes,
numberOfCoordinates=len(coordinates), numberOfCoordinates=len(coordinates),
coordinates = [x.get_pyxb_coordinate() for x in coordinates], coordinate = [x.get_pyxb_coordinate() for x in coordinates],
**dataproduct_map.get_dict()) **dataproduct_map.get_dict())
def get_pyxb_dataproduct(self): def get_pyxb_dataproduct(self):
return self.__pyxb_dataproduct return self.__pyxb_dataproduct
...@@ -205,8 +305,10 @@ class SkyImageDataProduct(): ...@@ -205,8 +305,10 @@ class SkyImageDataProduct():
locationframe, locationframe,
timeframe, timeframe,
observationpointing, observationpointing,
restoringbeammajor, restoringbeammajor_angle,
restoringbeamminor, restoringbeammajor_angleunit,
restoringbeamminor_angle,
restoringbeamminor_angleunit,
rmsnoise): rmsnoise):
self.__pyxb_dataproduct = ltasip.SkyImageDataProduct( self.__pyxb_dataproduct = ltasip.SkyImageDataProduct(
...@@ -215,9 +317,9 @@ class SkyImageDataProduct(): ...@@ -215,9 +317,9 @@ class SkyImageDataProduct():
coordinate = [x.get_pyxb_coordinate() for x in coordinates], coordinate = [x.get_pyxb_coordinate() for x in coordinates],
locationFrame=locationframe, locationFrame=locationframe,
timeFrame=timeframe, timeFrame=timeframe,
observationPointing=observationpointing, observationPointing=observationpointing.get_pyxb_pointing(),
restoringBeamMajor=restoringbeammajor, restoringBeamMajor=ltasip.Angle(restoringbeammajor_angle, units=restoringbeammajor_angleunit),
restoringBeamMinor=restoringbeamminor, restoringBeamMinor=ltasip.Angle(restoringbeamminor_angle, units=restoringbeamminor_angleunit),
rmsNoise=rmsnoise, rmsNoise=rmsnoise,
**dataproduct_map.get_dict()) **dataproduct_map.get_dict())
...@@ -306,11 +408,11 @@ class PulpDataProduct(): ...@@ -306,11 +408,11 @@ class PulpDataProduct():
dataproduct_map, dataproduct_map,
filecontent, filecontent,
datatype, datatype,
arrayBeam): arraybeam):
self.__pyxb_dataproduct = ltasip.PulpDataProduct( self.__pyxb_dataproduct = ltasip.PulpDataProduct(
fileContent=filecontent, fileContent=filecontent,
dataType=datatype, dataType=datatype,
arrayBeam=arraybeam.get_pyxb_beam(),
**dataproduct_map.get_dict()) **dataproduct_map.get_dict())
def get_pyxb_dataproduct(self): def get_pyxb_dataproduct(self):
...@@ -321,84 +423,170 @@ class PulpDataProduct(): ...@@ -321,84 +423,170 @@ class PulpDataProduct():
# ============ # ============
# Coordinates: # Coordinates:
class SpectralCoordinate():
class SpectralCoordinateLinear():
def __init__(self, def __init__(self,
quantity_type, quantity_type,
quantity_value, quantity_value,
linearaxis, axis,
): ):
self.__pyxb_coordinate=ltasip.SpectralCoordinate(
spectralLinearAxis=linearaxis.get_pyxb_axis(),
spectralQuantity=ltasip.SpectralQuantity(value_=quantity_value, type=quantity_type)
)
def get_pyxb_coordinate(self): args = dict(spectralQuantity=ltasip.SpectralQuantity(value_=quantity_value, type=quantity_type))
return self.__pyxb_coordinate
if isinstance(axis, LinearAxis):
args.update(dict(spectralLinearAxis=axis.get_pyxb_axis()))
elif isinstance(axis, TabularAxis):
args.update(dict(spectralTabularAxis=axis.get_pyxb_axis()))
else:
print "wrong axis type:",type(axis)
self.__pyxb_coordinate=ltasip.SpectralCoordinate(**args)
class SpectralCoordinateTabular():
def __init__(self,
quantity_type,
quantity_value,
tabularaxis,
):
self.__pyxb_coordinate=ltasip.SpectralCoordinate(
spectralTabularAxis=tabularaxis.get_pyxb_axis(),
spectralQuantity=ltasip.SpectralQuantity(value_=quantity_value, type=quantity_type)
)
def get_pyxb_coordinate(self): def get_pyxb_coordinate(self):
return self.__pyxb_coordinate return self.__pyxb_coordinate
class TimeCoordinateLinear(): class TimeCoordinate():
def __init__(self, def __init__(self,
equinox, equinox,
linearaxis, axis,
): ):
self.__pyxb_coordinate=ltasip.TimeCoordinate(
timeLinearAxis=linearaxis.get_pyxb_axis(), args = dict(equinox=equinox)
equinox=equinox
) if isinstance(axis, LinearAxis):
args.update(dict(timeLinearAxis=axis.get_pyxb_axis()))
elif isinstance(axis, TabularAxis):
args.update(dict(timeTabularAxis=axis.get_pyxb_axis()))
else:
print "wrong axis type:",type(axis)
self.__pyxb_coordinate=ltasip.TimeCoordinate(**args)
def get_pyxb_coordinate(self): def get_pyxb_coordinate(self):
return self.__pyxb_coordinate return self.__pyxb_coordinate
class PolarizationCoordinate():
class TimeCoordinateTabular():
def __init__(self, def __init__(self,
equinox,
tabularaxis, tabularaxis,
polarizations
): ):
self.__pyxb_coordinate=ltasip.PolarizationCoordinate(
self.__pyxb_coordinate=ltasip.TimeCoordinate( polarizationTabularAxis=tabularaxis.get_pyxb_axis(),
timeTabularAxis=tabularaxis.get_pyxb_axis(), polarization=polarizations)
equinox=equinox
)
def get_pyxb_coordinate(self): def get_pyxb_coordinate(self):
return self.__pyxb_coordinate return self.__pyxb_coordinate
class DirectionCoordinate(): class DirectionCoordinate():
def __init__(linearaxis_a, def __init__(self,
linearaxis_a,
linearaxis_b, linearaxis_b,
PC0_0, pc0_0,
PC0_1, pc0_1,
PC1_0, pc1_0,
PC1_1, pc1_1,
equinox, equinox,
raDecSystem, radecsystem,
projection, projection,
projectionParameters, projectionparameters,
longitudePole, longitudepole_angle,
latitudePole): longitudepole_angleunit,
pass latitudepole_angle,
#todo latitudepole_angleunit):
self.__pyxb_coordinate=ltasip.DirectionCoordinate(
directionLinearAxis=[linearaxis_a.get_pyxb_axis(), linearaxis_b.get_pyxb_axis()],
PC0_0=pc0_0,
PC0_1=pc0_1,
PC1_0=pc1_0,
PC1_1=pc1_1,
equinox=equinox,
raDecSystem=radecsystem,
projection=projection,
projectionParameters=projectionparameters,
longitudePole=ltasip.Angle(longitudepole_angle, units=longitudepole_angleunit),
latitudePole=ltasip.Angle(latitudepole_angle, units=latitudepole_angleunit)
)
def get_pyxb_coordinate(self):
return self.__pyxb_coordinate
# ########
# Others:
class ArrayBeam():
def __init__(self,
subarraypointingidentifier_source,
subarraypointingidentifier,
beamnumber,
dispersionmeasure,
numberofsubbands,
stationsubbands,
samplingtime,
samplingtimeunit,
centralfrequencies,
centralfrequencies_unit,
channelwidth_frequency,
channelwidth_frequencyunit,
channelspersubband,
stokes):
self.__pyxb_beam=ltasip.ArrayBeam(
subArrayPointingIdentifier=ltasip.IdentifierType(source=subarraypointingidentifier_source, identifier=subarraypointingidentifier),
beamNumber=beamnumber,
dispersionMeasure=dispersionmeasure,
numberOfSubbands=numberofsubbands,
stationSubbands=stationsubbands,
samplingTime=ltasip.Time(samplingtime, units=samplingtimeunit),
centralFrequencies=ltasip.ListOfFrequencies(frequencies=centralfrequencies, unit=centralfrequencies_unit),
channelWidth=ltasip.Frequency(channelwidth_frequency, units=channelwidth_frequencyunit),
channelsPerSubband=channelspersubband,
stokes=stokes
)
def get_pyxb_beam(self):
return self.__pyxb_beam
class PointingRaDec():
def __init__(self,
ra_angle,
ra_angleunit,
dec_angle,
dec_angleunit,
equinox):
self.__pyxb_pointing=ltasip.Pointing(
rightAscension=ltasip.Angle(ra_angle, units=ra_angleunit),
declination=ltasip.Angle(dec_angle, units=dec_angleunit),
equinox=equinox)
def get_pyxb_pointing(self):
return self.__pyxb_pointing
class PointingAltAz():
def __init__(self,
az_angle,
az_angleunit,
alt_angle,
alt_angleunit,
equinox):
self.__pyxb_pointing=ltasip.Pointing(
azimuth=ltasip.Angle(az_angle, units=az_angleunit),
altitude=ltasip.Angle(alt_angle, units=alt_angleunit),
equinox=equinox)
def get_pyxb_pointing(self):
return self.__pyxb_pointing
class LinearAxis(): class LinearAxis():
def __init__(self, def __init__(self,
...@@ -441,12 +629,110 @@ class TabularAxis(): ...@@ -441,12 +629,110 @@ class TabularAxis():
def get_pyxb_axis(self): def get_pyxb_axis(self):
return self.__pyxb_axis return self.__pyxb_axis
class CorrelatorProcessing():
def __init__(self,
integrationinterval,
integrationinterval_unit,
channelwidth_frequency=None,
channelwidth_frequencyunit=None,
channelspersubband=None,
processingtype="Correlator",
):
self.__pyxb_rtprocessing=ltasip.Correlator(
integrationInterval=ltasip.Time(integrationinterval,units=integrationinterval_unit),
processingType=processingtype,
channelWidth=ltasip.Frequency(channelwidth_frequency, units=channelwidth_frequencyunit),
channelsPerSubband=channelspersubband
)
def get_pyxb_rtprocessing(self):
return self.__pyxb_rtprocessing
class CoherentStokesProcessing():
#todo
def get_pyxb_rtprocessing(self):
return self.__pyxb_rtprocessing
class IncoherentStokesProcessing():
#todo
def get_pyxb_rtprocessing(self):
return self.__pyxb_rtprocessing
class FlysEyeProcessing():
#todo
def get_pyxb_rtprocessing(self):
return self.__pyxb_rtprocessing
class NonStandardProcessing():
#todo
def get_pyxb_rtprocessing(self):
return self.__pyxb_rtprocessing
class SubArrayPointing():
def __init__(self,
pointing,
beamnumber,
subarraypointingidentifier,
subarraypointingidentifier_source,
measurementtype,
targetname,
starttime,
duration,
numberofprocessing,
numberofcorrelateddataproducts,
numberofbeamformeddataproducts,
relations,
correlatorprocessing=None,
coherentstokesprocessing=None,
incoherentstokesprocessing=None,
flyseyeprocessing=None,
nonstandardprocessing=None,
measurementdescription=None):
__relations=ltasip.ProcessRelations()
for rel in relations:
__relations.append(rel.get_pyxb_processrelation())
__processing=None
for processing in [correlatorprocessing, coherentstokesprocessing, incoherentstokesprocessing, flyseyeprocessing, nonstandardprocessing]:
if processing:
if __processing is None:
__processing=ltasip.Processing()
__processing.append(correlatorprocessing.get_pyxb_rtprocessing()
)
self.__pyxb_subarraypointing = ltasip.SubArrayPointing(
pointing=pointing.get_pyxb_pointing(),
beamNumber=beamnumber,
subArrayPointingIdentifier=ltasip.IdentifierType(identifier=subarraypointingidentifier,source=subarraypointingidentifier_source),
measurementType=measurementtype,
targetName=targetname,
startTime=starttime,
duration=duration,
numberOfProcessing=numberofprocessing,
numberOfCorrelatedDataProducts=numberofcorrelateddataproducts,
numberOfBeamFormedDataProducts=numberofbeamformeddataproducts,
processing=__processing,
relations=__relations,
measurementDescription=measurementdescription)
def get_pyxb_subarraypointing(self):
return self.__pyxb_subarraypointing
# #############################################################################################
# ============ # ============
# SIP document # SIP document
class Sip(): class Sip():
print "\n################"
print VERSION
print "################\n"
print "===\nCreating base document...\n"
sip = ltasip.ltaSip() sip = ltasip.ltaSip()
#----------- #-----------
...@@ -471,7 +757,6 @@ class Sip(): ...@@ -471,7 +757,6 @@ class Sip():
contactAuthor=project_contactauthor, contactAuthor=project_contactauthor,
telescope=project_telescope, telescope=project_telescope,
projectDescription=project_description, projectDescription=project_description,
#dataProduct=dataproduct,
coInvestigator=project_coinvestigators, coInvestigator=project_coinvestigators,
) )
...@@ -488,7 +773,6 @@ class Sip(): ...@@ -488,7 +773,6 @@ class Sip():
self.sip.relatedDataProduct.append(dataproduct.get_pyxb_dataproduct()) self.sip.relatedDataProduct.append(dataproduct.get_pyxb_dataproduct())
return self.get_prettyxml() return self.get_prettyxml()
# todo: subarraypointings, transientbufferboardevents
def add_observation(self, def add_observation(self,
observingmode, observingmode,
instrumentfilter, instrumentfilter,
...@@ -509,13 +793,25 @@ class Sip(): ...@@ -509,13 +793,25 @@ class Sip():
channelwidth_frequencyunit=None, channelwidth_frequencyunit=None,
observationdescription=None, observationdescription=None,
channelspersubband=None, channelspersubband=None,
subarraypointings=None, #" type="SubArrayPointings"/> subarraypointings=None,
transientbufferboardevents=None #" type="TransientBufferBoardEvents"/> transientbufferboardevents=None
): ):
stations = ltasip.Stations() __stations = ltasip.Stations()
for station in stationlist: for station in stationlist:
stations.append(station) __stations.append(station)
__tbbevents=None,
if(transientbufferboardevents):
__tbbevents = ltasip.TransientBufferBoardEvents()
for source in transientbufferboardevents:
__tbbevents.append(ltasip.TransientBufferBoardEvent(eventSource=source))
__pointings=None
if(subarraypointings):
__pointings = ltasip.SubArrayPointings()
for point in subarraypointings:
__pointings.append(point.get_pyxb_subarraypointing())
obs = ltasip.Observation( obs = ltasip.Observation(
observingMode=observingmode, observingMode=observingmode,
...@@ -525,7 +821,7 @@ class Sip(): ...@@ -525,7 +821,7 @@ class Sip():
antennaSet=antennaset, antennaSet=antennaset,
timeSystem=timesystem, timeSystem=timesystem,
numberOfStations=numberofstations, numberOfStations=numberofstations,
stations=stations, stations=__stations,
numberOfSubArrayPointings=numberofsubarraypointings, numberOfSubArrayPointings=numberofsubarraypointings,
numberOftransientBufferBoardEvents=numberoftbbevents, numberOftransientBufferBoardEvents=numberoftbbevents,
numberOfCorrelatedDataProducts=numberofcorrelateddataproducts, numberOfCorrelatedDataProducts=numberofcorrelateddataproducts,
...@@ -534,8 +830,8 @@ class Sip(): ...@@ -534,8 +830,8 @@ class Sip():
observationDescription=observationdescription, observationDescription=observationdescription,
channelWidth=ltasip.Frequency(channelwidth_frequency, units=channelwidth_frequencyunit), channelWidth=ltasip.Frequency(channelwidth_frequency, units=channelwidth_frequencyunit),
channelsPerSubband=channelspersubband, channelsPerSubband=channelspersubband,
subArrayPointings=None, #" type="SubArrayPointings"/> subArrayPointings=__pointings,
transientBufferBoardEvents=None, #" type="TransientBufferBoardEvents"/> transientBufferBoardEvents=__tbbevents,
**process_map.get_dict() **process_map.get_dict()
) )
...@@ -544,11 +840,11 @@ class Sip(): ...@@ -544,11 +840,11 @@ class Sip():
def add_pipelinerun(self): def add_pipelinerun(self, pipeline):
self.sip.pipelineRun.append(pipeline.get_pyxb_pipeline())
return self.get_prettyxml() return self.get_prettyxml()
# todo relations
def add_unspecifiedprocess(self, def add_unspecifiedprocess(self,
observingmode, observingmode,
description, description,
...@@ -578,6 +874,7 @@ class Sip(): ...@@ -578,6 +874,7 @@ class Sip():
return self.get_prettyxml() return self.get_prettyxml()
# this will also validate the document so far
def get_prettyxml(self): def get_prettyxml(self):
try: try:
return self.sip.toDOM().toprettyxml() return self.sip.toDOM().toprettyxml()
...@@ -592,10 +889,22 @@ class Sip(): ...@@ -592,10 +889,22 @@ class Sip():
# ########################################################## end SIP class # ########################################################## end SIP class
# ############################################################################
def main(): def main():
# todo: This should be moved to testing, but makes it easier for me now. # todo: This should be moved to testing, but makes it easier for me now.
...@@ -623,16 +932,11 @@ def main(): ...@@ -623,16 +932,11 @@ def main():
) )
) )
) )
# add optional attributes
# mysip.add_project_coInvestigator("sidekick3")
# mysip.add_dataproduct_checksum("MD5", "anotherchecksum")
print "===\nCreated base document:\n"
mysip.prettyprint() mysip.prettyprint()
print "===\nAdding related generic dataproduct:\n"
# add optional dataproduct item # add optional dataproduct item
mysip.add_related_dataproduct( print mysip.add_related_dataproduct(
GenericDataProduct( GenericDataProduct(
DataProductMap( DataProductMap(
type="Unknown", type="Unknown",
...@@ -647,13 +951,66 @@ def main(): ...@@ -647,13 +951,66 @@ def main():
) )
) )
print "===\nAdded related dataproduct:\n"
mysip.prettyprint() # add optional dataproduct item
print "===\nAdding related pulp summary dataproduct:\n"
print mysip.add_related_dataproduct(
PulpSummaryDataProduct(
DataProductMap(
type="Unknown",
source="space",
identifier="fourtytwo",
size=2048,
filename="/home/paulus/test.h5",
fileformat="HDF5",
processsource="someone gave it to me",
processid="SIPlib 0.1"
),
filecontent=["content_a","content_b"],
datatype="CoherentStokes"
)
)
# add optional dataproduct item
print "===\nAdding related pulp dataproduct:\n"
print mysip.add_related_dataproduct(
PulpDataProduct(
DataProductMap(
type="Unknown",
source="space",
identifier="fourtytwo",
size=2048,
filename="/home/paulus/test.h5",
fileformat="HDF5",
processsource="someone gave it to me",
processid="SIPlib 0.1"
),
filecontent=["content_a","content_b"],
datatype="CoherentStokes",
arraybeam=ArrayBeam(
subarraypointingidentifier_source="source",
subarraypointingidentifier="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 # add optional dataproduct item
mysip.add_related_dataproduct( print "===\nAdding related sky image dataproduct:\n"
print mysip.add_related_dataproduct(
SkyImageDataProduct( SkyImageDataProduct(
DataProductMap( DataProductMap(
type="Unknown", type="Unknown",
...@@ -667,10 +1024,10 @@ def main(): ...@@ -667,10 +1024,10 @@ def main():
), ),
numberofaxes=2, numberofaxes=2,
coordinates=[ coordinates=[
SpectralCoordinateLinear( SpectralCoordinate(
quantity_type="Frequency", quantity_type="Frequency",
quantity_value=20.0, quantity_value=20.0,
linearaxis=LinearAxis( axis=LinearAxis(
number=5, number=5,
name="bla", name="bla",
units="parsec", units="parsec",
...@@ -678,36 +1035,85 @@ def main(): ...@@ -678,36 +1035,85 @@ def main():
increment=5, increment=5,
referencepixel=7.5, referencepixel=7.5,
referencevalue=7.4)), referencevalue=7.4)),
SpectralCoordinateTabular( SpectralCoordinate(
quantity_type="Frequency", quantity_type="Frequency",
quantity_value=20.0, quantity_value=20.0,
axis=TabularAxis(
number=5,
name="bla",
units="parsec",
length=5,
)),
DirectionCoordinate(
linearaxis_a=LinearAxis(
number=5,
name="bla",
units="parsec",
length=5,
increment=5,
referencepixel=7.5,
referencevalue=7.4),
linearaxis_b=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",
),
PolarizationCoordinate(
tabularaxis=TabularAxis( tabularaxis=TabularAxis(
number=5, number=5,
name="bla", name="bla",
units="parsec", units="parsec",
length=5, length=5,
)) ),
polarizations=["I","YY","XX","Q"]
),
TimeCoordinate(
equinox="SUN",
axis=TabularAxis(
number=5,
name="timetabular",
units="parsec",
length=5,
),
)
], ],
locationframe="GEOCENTER", locationframe="GEOCENTER",
timeframe="timeframe", timeframe="timeframe",
observationpointing=ltasip.Pointing( observationpointing=PointingRaDec(
rightAscension=ltasip.Angle(2.0, units="degrees"), ra_angle=1.0,
#azimuth=ltasip.Angle(), ra_angleunit="degrees",
declination=ltasip.Angle(2.0, units="degrees"), dec_angle=42.0,
#altitude=ltasip.Angle(), dec_angleunit="degrees",
equinox="SUN"), equinox="SUN"
restoringbeammajor=ltasip.Angle(2.0, units="degrees"), ),
restoringbeamminor=ltasip.Angle(2.0, units="degrees"), restoringbeammajor_angle=1.0,
restoringbeammajor_angleunit="degrees",
restoringbeamminor_angle=2.0,
restoringbeamminor_angleunit="degrees",
rmsnoise=ltasip.Pixel("1.0", units="Jy/beam") rmsnoise=ltasip.Pixel("1.0", units="Jy/beam")
) )
) )
print "===\nAdded another related dataproduct:\n"
mysip.prettyprint()
# add optional dataproduct item # add optional dataproduct item
mysip.add_related_dataproduct( print "===\nAdded related correlated dataproduct:\n"
print mysip.add_related_dataproduct(
CorrelatedDataProduct( CorrelatedDataProduct(
DataProductMap( DataProductMap(
type="Unknown", type="Unknown",
...@@ -735,12 +1141,40 @@ def main(): ...@@ -735,12 +1141,40 @@ def main():
) )
) )
print "===\nAdded yet another related dataproduct:\n" # add optional dataproduct item
mysip.prettyprint() print "===\nAdding related pixelmap dataproduct:\n"
print mysip.add_related_dataproduct(
PixelMapDataProduct(
DataProductMap(
type="Unknown",
source="space",
identifier="fourtytwo",
size=2048,
filename="/home/paulus/test.h5",
fileformat="HDF5",
processsource="someone gave it to me",
processid="SIPlib 0.1"
),
numberofaxes=5,
coordinates=[SpectralCoordinate(
quantity_type="Frequency",
quantity_value=20.0,
axis=LinearAxis(
number=5,
name="bla",
units="parsec",
length=5,
increment=5,
referencepixel=7.5,
referencevalue=7.4))]
)
)
# add optional observation item # add optional observation item
mysip.add_observation(observingmode="Interferometer", print "===\nAdding observation:\n"
print mysip.add_observation(observingmode="Interferometer",
instrumentfilter="10-70 MHz", instrumentfilter="10-70 MHz",
clock_frequency='160', clock_frequency='160',
clock_frequencyunit="MHz", clock_frequencyunit="MHz",
...@@ -765,25 +1199,54 @@ def main(): ...@@ -765,25 +1199,54 @@ def main():
process_source="MoM", process_source="MoM",
process_id="MoM Id", process_id="MoM Id",
parset_source="parsource", parset_source="parsource",
parset_id="parid" parset_id="parid",
relations=[ProcessRelation(
identifier_source="source",
identifier="90")]
), ),
observationdescription="description", observationdescription="description",
channelwidth_frequency=160, channelwidth_frequency=160,
channelwidth_frequencyunit="MHz", channelwidth_frequencyunit="MHz",
channelspersubband=5, channelspersubband=5,
subarraypointings=None, #" type="SubArrayPointings"/> subarraypointings=[SubArrayPointing(
transientbufferboardevents=None #" type="TransientBufferBoardEvents"/> pointing=PointingAltAz(
az_angle=20,
az_angleunit="degrees",
alt_angle=30,
alt_angleunit="degrees",
equinox="SUN"
),
beamnumber=5,
subarraypointingidentifier="id",
subarraypointingidentifier_source="idsource",
measurementtype="All Sky",
targetname="Sun",
starttime="1980-03-23T10:20:15",
duration= "P6Y3M10DT15H",
numberofprocessing=1,
numberofcorrelateddataproducts=2,
numberofbeamformeddataproducts=1,
relations=[ProcessRelation(
identifier_source="source",
identifier="90")],
correlatorprocessing=CorrelatorProcessing(
integrationinterval=0.5,
integrationinterval_unit="ns",
channelwidth_frequency=160,
channelwidth_frequencyunit="MHz"
)
)],
transientbufferboardevents=["event1","event2"]
) )
print "===\nAdded observation:\n" print "===\nAdding parset:\n"
mysip.prettyprint() print mysip.add_parset(
source="Unknkown",
mysip.add_parset(source="Unknkown",identifier="Parset1", contents="blabla") identifier="Parset1",
contents="blabla")
print "===\nAdded parset:\n"
mysip.prettyprint()
mysip.add_unspecifiedprocess( print "===\nAdding unspecified process:\n"
print mysip.add_unspecifiedprocess(
observingmode="Interferometer", observingmode="Interferometer",
description="unspecified", description="unspecified",
process_map= process_map=
...@@ -797,11 +1260,140 @@ def main(): ...@@ -797,11 +1260,140 @@ def main():
process_source="MoM", process_source="MoM",
process_id="MoM Id", process_id="MoM Id",
parset_source="parsource", parset_source="parsource",
parset_id="parid") parset_id="parid",
relations=[ProcessRelation(
identifier_source="source",
identifier="90",
name="name"),
ProcessRelation(
identifier_source="sourceB",
identifier="7",
name="another name")
]
)
) )
print "===\nAdded unspecified process:\n" print "===\nAdding simple pipelinerun:\n"
mysip.prettyprint() print mysip.add_pipelinerun(
SimplePipeline(
PipelineMap(
name="simple",
version="version",
sourcedata_identifiers=["ID1","ID2"],
sourcedata_source="space",
process_map=ProcessMap(
strategyname="strategy1",
strategydescription="awesome strategy",
starttime="1980-03-23T10:20:15",
duration= "P6Y3M10DT15H",
observation_source="SAS",
observation_id="SAS VIC Tree Id",
process_source="MoM",
process_id="MoM Id",
parset_source="parsource",
parset_id="parid",
relations=[
ProcessRelation(
identifier_source="source",
identifier="90")]
),
)
)
)
print "===\nAdding generic pipelinerun:\n"
print mysip.add_pipelinerun(
GenericPipeline(
PipelineMap(
name="generic",
version="version",
sourcedata_identifiers=["ID1","ID2"],
sourcedata_source="space",
process_map=ProcessMap(
strategyname="strategy1",
strategydescription="awesome strategy",
starttime="1980-03-23T10:20:15",
duration= "P6Y3M10DT15H",
observation_source="SAS",
observation_id="SAS VIC Tree Id",
process_source="MoM",
process_id="MoM Id",
parset_source="parsource",
parset_id="parid",
relations=[
ProcessRelation(
identifier_source="source",
identifier="90")]
),
)
)
)
print "===\nAdding cosmic ray pipelinerun:\n"
print mysip.add_pipelinerun(
CosmicRayPipeline(
PipelineMap(
name="cosmic ray",
version="version",
sourcedata_identifiers=["ID1","ID2"],
sourcedata_source="space",
process_map=ProcessMap(
strategyname="strategy1",
strategydescription="awesome strategy",
starttime="1980-03-23T10:20:15",
duration= "P6Y3M10DT15H",
observation_source="SAS",
observation_id="SAS VIC Tree Id",
process_source="MoM",
process_id="MoM Id",
parset_source="parsource",
parset_id="parid",
relations=[
ProcessRelation(
identifier_source="source",
identifier="90")]
),
)
)
)
print "===\nAdding long baseline pipelinerun:\n"
print mysip.add_pipelinerun(
LongBaselinePipeline(
PipelineMap(
name="long baseline",
version="version",
sourcedata_identifiers=["ID1","ID2"],
sourcedata_source="space",
process_map=ProcessMap(
strategyname="strategy1",
strategydescription="awesome strategy",
starttime="1980-03-23T10:20:15",
duration= "P6Y3M10DT15H",
observation_source="SAS",
observation_id="SAS VIC Tree Id",
process_source="MoM",
process_id="MoM Id",
parset_source="parsource",
parset_id="parid",
relations=[
ProcessRelation(
identifier_source="source",
identifier="90")]
),
),
subbandspersubbandgroup=5,
subbandgroupspermS=5
)
)
#path = os.path.expanduser("~/sip9091.xml")
#with open(path, 'w+') as f:
# f.write(mysip.get_prettyxml())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment