Skip to content
Snippets Groups Projects
Commit 2215bc3e authored by Mattia Mancini's avatar Mattia Mancini
Browse files

Remove unused import and reformat file

parent 4d67fc0e
No related branches found
No related tags found
No related merge requests found
...@@ -29,22 +29,18 @@ from . import ltasip ...@@ -29,22 +29,18 @@ from . import ltasip
import pyxb import pyxb
from . import constants from . import constants
import os import os
import uuid
import xml.dom.minidom
from pyxb.namespace import XMLSchema_instance as xsi
from pyxb.namespace import XMLNamespaces as xmlns
from . import query from . import query
VERSION = "SIPlib 0.4" VERSION = "SIPlib 0.4"
d = os.path.dirname(os.path.realpath(__file__)) d = os.path.dirname(os.path.realpath(__file__))
STATION_CONFIG_PATH = d + '/station_coordinates.conf' STATION_CONFIG_PATH = d + '/station_coordinates.conf'
ltasip.Namespace.setPrefix('sip') ltasip.Namespace.setPrefix('sip')
# todo: create docstrings for everything. # todo: create docstrings for everything.
# specify types and explain purpose of the field (-> ask someone with more astronomical background) # specify types and explain purpose of the field (-> ask someone with more astronomical background)
# todo: check what fields can be implicitely set # todo: check what fields can be implicitly set
# (e.g. parameter type in dataproduct may be derived from the specific dataproduct class that is used) # (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 # Some parameters may also be filled with a reasonable default value. Right now, usually only optional values
# as per schema definition are optional parameters. # as per schema definition are optional parameters.
...@@ -60,11 +56,13 @@ def print_user_warning(): ...@@ -60,11 +56,13 @@ def print_user_warning():
print("!!! might break for you without further warning.") print("!!! might break for you without further warning.")
print("!!! (You may suppress this warning by setting the flag in the pyxb-related getter/setter functions.)") print("!!! (You may suppress this warning by setting the flag in the pyxb-related getter/setter functions.)")
# =============================== # ===============================
# Identifier definition (used for LTA entities, i-e- processes and dataproducts): # Identifier definition (used for LTA entities, i-e- processes and dataproducts):
class Identifier(object): class Identifier(object):
""" Identifier for LTA entities. """ """ Identifier for LTA entities. """
def __init__(self, def __init__(self,
source, source,
userlabel=None, userlabel=None,
...@@ -111,6 +109,7 @@ class Identifier(object): ...@@ -111,6 +109,7 @@ class Identifier(object):
print_user_warning() print_user_warning()
return self.__pyxb_identifier return self.__pyxb_identifier
# =============================== # ===============================
# Station definitions: # Station definitions:
...@@ -144,13 +143,15 @@ class Station(): ...@@ -144,13 +143,15 @@ class Station():
with open(STATION_CONFIG_PATH, 'r') as f: with open(STATION_CONFIG_PATH, 'r') as f:
for line in f.readlines(): for line in f.readlines():
if line.strip(): if line.strip():
field_coords = eval("dict("+line+")") # literal_eval does not accept dict definition via constructor. Make sure config file is not writable to prevent code execution! field_coords = eval(
"dict(" + line + ")") # literal_eval does not accept dict definition via constructor. Make sure config file is not writable to prevent code execution!
for type in antennafieldtypes: for type in antennafieldtypes:
if field_coords["name"] == name + "_" + type: if field_coords["name"] == name + "_" + type:
__afield = AntennafieldXYZ( __afield = AntennafieldXYZ(
type=type, type=type,
coordinate_system=field_coords["coordinate_system"], coordinate_system=field_coords["coordinate_system"],
coordinate_unit=constants.LENGTHUNIT_M, # Does this make sense? I have to give a lenght unit accoridng to the XSD, but ICRF should be decimal degrees?! coordinate_unit=constants.LENGTHUNIT_M,
# Does this make sense? I have to give a lenght unit accoridng to the XSD, but ICRF should be decimal degrees?!
coordinate_x=field_coords["x"], coordinate_x=field_coords["x"],
coordinate_y=field_coords["y"], coordinate_y=field_coords["y"],
coordinate_z=field_coords["z"]) coordinate_z=field_coords["z"])
...@@ -182,7 +183,6 @@ class Station(): ...@@ -182,7 +183,6 @@ class Station():
return self.__pyxb_station return self.__pyxb_station
class AntennafieldXYZ(): class AntennafieldXYZ():
def __init__(self, def __init__(self,
type, type,
...@@ -206,6 +206,7 @@ class AntennafieldXYZ(): ...@@ -206,6 +206,7 @@ class AntennafieldXYZ():
print_user_warning() print_user_warning()
return self.__pyxb_antennafield return self.__pyxb_antennafield
class AntennafieldRadLonLat(): class AntennafieldRadLonLat():
def __init__(self, def __init__(self,
type, type,
...@@ -242,7 +243,6 @@ class PipelineMap(): ...@@ -242,7 +243,6 @@ class PipelineMap():
sourcedata_identifiers, sourcedata_identifiers,
process_map process_map
): ):
__sourcedata = ltasip.DataSources() __sourcedata = ltasip.DataSources()
for identifier in sourcedata_identifiers: for identifier in sourcedata_identifiers:
__sourcedata.append(identifier._get_pyxb_identifier(suppress_warning=True)) __sourcedata.append(identifier._get_pyxb_identifier(suppress_warning=True))
...@@ -281,7 +281,6 @@ class ImagingPipeline(): ...@@ -281,7 +281,6 @@ class ImagingPipeline():
timeintegrationstep=None, timeintegrationstep=None,
skymodeldatabase=None, skymodeldatabase=None,
demixing=None): demixing=None):
self.__pyxb_pipeline = ltasip.ImagingPipeline( self.__pyxb_pipeline = ltasip.ImagingPipeline(
frequencyIntegrationStep=frequencyintegrationstep, frequencyIntegrationStep=frequencyintegrationstep,
timeIntegrationStep=timeintegrationstep, timeIntegrationStep=timeintegrationstep,
...@@ -325,6 +324,7 @@ class CalibrationPipeline(): ...@@ -325,6 +324,7 @@ class CalibrationPipeline():
def _get_pyxb_pipeline(self, suppress_warning=False): def _get_pyxb_pipeline(self, suppress_warning=False):
return self.__pyxb_pipeline return self.__pyxb_pipeline
class AveragingPipeline(): class AveragingPipeline():
def __init__(self, def __init__(self,
pipeline_map, pipeline_map,
...@@ -365,7 +365,6 @@ class PulsarPipeline(): ...@@ -365,7 +365,6 @@ class PulsarPipeline():
runrotationalradiotransientsanalysis, runrotationalradiotransientsanalysis,
skipdynamicspectrum, skipdynamicspectrum,
skipprefold): skipprefold):
self.__pyxb_pipeline = ltasip.PulsarPipeline( self.__pyxb_pipeline = ltasip.PulsarPipeline(
pulsarSelection=pulsarselection, pulsarSelection=pulsarselection,
pulsars=pulsars, pulsars=pulsars,
...@@ -381,11 +380,13 @@ class PulsarPipeline(): ...@@ -381,11 +380,13 @@ class PulsarPipeline():
skipPreFold=skipprefold, skipPreFold=skipprefold,
**pipeline_map.get_dict() **pipeline_map.get_dict()
) )
def _get_pyxb_pipeline(self, suppress_warning=False): def _get_pyxb_pipeline(self, suppress_warning=False):
if not suppress_warning: if not suppress_warning:
print_user_warning() print_user_warning()
return self.__pyxb_pipeline return self.__pyxb_pipeline
class CosmicRayPipeline(): class CosmicRayPipeline():
def __init__(self, pipeline_map): def __init__(self, pipeline_map):
self.__pyxb_pipeline = ltasip.CosmicRayPipeline(**pipeline_map.get_dict()) self.__pyxb_pipeline = ltasip.CosmicRayPipeline(**pipeline_map.get_dict())
...@@ -395,6 +396,7 @@ class CosmicRayPipeline(): ...@@ -395,6 +396,7 @@ class CosmicRayPipeline():
print_user_warning() print_user_warning()
return self.__pyxb_pipeline return self.__pyxb_pipeline
class LongBaselinePipeline(): class LongBaselinePipeline():
def __init__(self, def __init__(self,
pipeline_map, pipeline_map,
...@@ -411,6 +413,7 @@ class LongBaselinePipeline(): ...@@ -411,6 +413,7 @@ class LongBaselinePipeline():
print_user_warning() print_user_warning()
return self.__pyxb_pipeline return self.__pyxb_pipeline
class GenericPipeline(): class GenericPipeline():
def __init__(self, pipeline_map): def __init__(self, pipeline_map):
self.__pyxb_pipeline = ltasip.GenericPipeline(**pipeline_map.get_dict()) self.__pyxb_pipeline = ltasip.GenericPipeline(**pipeline_map.get_dict())
...@@ -421,8 +424,6 @@ class GenericPipeline(): ...@@ -421,8 +424,6 @@ class GenericPipeline():
return self.__pyxb_pipeline return self.__pyxb_pipeline
# ========== # ==========
# Dataproducts: # Dataproducts:
...@@ -479,12 +480,14 @@ class SimpleDataProduct(__DataProduct): ...@@ -479,12 +480,14 @@ class SimpleDataProduct(__DataProduct):
ltasip.DataProduct(**dataproduct_map.get_dict()) ltasip.DataProduct(**dataproduct_map.get_dict())
) )
class SkyModelDataProduct(__DataProduct): class SkyModelDataProduct(__DataProduct):
def __init__(self, dataproduct_map): def __init__(self, dataproduct_map):
super(SkyModelDataProduct, self).__init__( super(SkyModelDataProduct, self).__init__(
ltasip.SkyModelDataProduct(**dataproduct_map.get_dict()) ltasip.SkyModelDataProduct(**dataproduct_map.get_dict())
) )
class GenericDataProduct(__DataProduct): class GenericDataProduct(__DataProduct):
def __init__(self, dataproduct_map): def __init__(self, dataproduct_map):
super(GenericDataProduct, self).__init__( super(GenericDataProduct, self).__init__(
...@@ -526,8 +529,6 @@ class SkyImageDataProduct(__DataProduct): ...@@ -526,8 +529,6 @@ class SkyImageDataProduct(__DataProduct):
restoringbeamminor_angle, restoringbeamminor_angle,
restoringbeamminor_angleunit, restoringbeamminor_angleunit,
rmsnoise): rmsnoise):
super(SkyImageDataProduct, self).__init__( super(SkyImageDataProduct, self).__init__(
ltasip.SkyImageDataProduct( ltasip.SkyImageDataProduct(
numberOfAxes=numberofaxes, numberOfAxes=numberofaxes,
...@@ -543,7 +544,6 @@ class SkyImageDataProduct(__DataProduct): ...@@ -543,7 +544,6 @@ class SkyImageDataProduct(__DataProduct):
) )
class CorrelatedDataProduct(__DataProduct): class CorrelatedDataProduct(__DataProduct):
def __init__(self, def __init__(self,
dataproduct_map, dataproduct_map,
...@@ -578,7 +578,6 @@ class CorrelatedDataProduct(__DataProduct): ...@@ -578,7 +578,6 @@ class CorrelatedDataProduct(__DataProduct):
self.__pyxb_dataproduct.subArrayPointingIdentifier = identifier._get_pyxb_identifier(suppress_warning=True) self.__pyxb_dataproduct.subArrayPointingIdentifier = identifier._get_pyxb_identifier(suppress_warning=True)
class InstrumentModelDataProduct(__DataProduct): class InstrumentModelDataProduct(__DataProduct):
def __init__(self, dataproduct_map): def __init__(self, dataproduct_map):
super(InstrumentModelDataProduct, self).__init__( super(InstrumentModelDataProduct, self).__init__(
...@@ -607,7 +606,6 @@ class PulpSummaryDataProduct(__DataProduct): ...@@ -607,7 +606,6 @@ class PulpSummaryDataProduct(__DataProduct):
dataproduct_map, dataproduct_map,
filecontent, filecontent,
datatype): datatype):
super(PulpSummaryDataProduct, self).__init__( super(PulpSummaryDataProduct, self).__init__(
ltasip.PulpSummaryDataProduct( ltasip.PulpSummaryDataProduct(
fileContent=filecontent, fileContent=filecontent,
...@@ -622,7 +620,6 @@ class PulpDataProduct(__DataProduct): ...@@ -622,7 +620,6 @@ class PulpDataProduct(__DataProduct):
filecontent, filecontent,
datatype, datatype,
arraybeam): arraybeam):
super(PulpDataProduct, self).__init__( super(PulpDataProduct, self).__init__(
ltasip.PulpDataProduct( ltasip.PulpDataProduct(
fileContent=filecontent, fileContent=filecontent,
...@@ -653,8 +650,6 @@ class BeamFormedDataProduct(__DataProduct): ...@@ -653,8 +650,6 @@ class BeamFormedDataProduct(__DataProduct):
) )
# ============ # ============
# Coordinates: # Coordinates:
...@@ -699,7 +694,6 @@ class TimeCoordinate(): ...@@ -699,7 +694,6 @@ class TimeCoordinate():
self.__pyxb_coordinate = ltasip.TimeCoordinate(**args) self.__pyxb_coordinate = ltasip.TimeCoordinate(**args)
def _get_pyxb_coordinate(self, suppress_warning=False): def _get_pyxb_coordinate(self, suppress_warning=False):
if not suppress_warning: if not suppress_warning:
print_user_warning() print_user_warning()
...@@ -737,9 +731,9 @@ class DirectionCoordinate(): ...@@ -737,9 +731,9 @@ class DirectionCoordinate():
longitudepole_angleunit, longitudepole_angleunit,
latitudepole_angle, latitudepole_angle,
latitudepole_angleunit): latitudepole_angleunit):
self.__pyxb_coordinate = ltasip.DirectionCoordinate( self.__pyxb_coordinate = ltasip.DirectionCoordinate(
directionLinearAxis=[linearaxis_a._get_pyxb_axis(suppress_warning=True), linearaxis_b._get_pyxb_axis(suppress_warning=True)], directionLinearAxis=[linearaxis_a._get_pyxb_axis(suppress_warning=True),
linearaxis_b._get_pyxb_axis(suppress_warning=True)],
PC0_0=pc0_0, PC0_0=pc0_0,
PC0_1=pc0_1, PC0_1=pc0_1,
PC1_0=pc1_0, PC1_0=pc1_0,
...@@ -757,6 +751,7 @@ class DirectionCoordinate(): ...@@ -757,6 +751,7 @@ class DirectionCoordinate():
print_user_warning() print_user_warning()
return self.__pyxb_coordinate return self.__pyxb_coordinate
# ########### # ###########
# ArrayBeams: # ArrayBeams:
...@@ -791,6 +786,7 @@ class ArrayBeamMap(): ...@@ -791,6 +786,7 @@ class ArrayBeamMap():
def get_dict(self): def get_dict(self):
return self.arraybeam_map return self.arraybeam_map
class SimpleArrayBeam(): class SimpleArrayBeam():
def __init__(self, arraybeam_map): def __init__(self, arraybeam_map):
self.__pyxb_beam = ltasip.ArrayBeam(**arraybeam_map.get_dict()) self.__pyxb_beam = ltasip.ArrayBeam(**arraybeam_map.get_dict())
...@@ -873,6 +869,7 @@ class CorrelatorProcessing(): ...@@ -873,6 +869,7 @@ class CorrelatorProcessing():
print_user_warning() print_user_warning()
return self.__pyxb_rtprocessing return self.__pyxb_rtprocessing
class CoherentStokesProcessing(): class CoherentStokesProcessing():
def __init__(self, def __init__(self,
rawsamplingtime, rawsamplingtime,
...@@ -921,6 +918,7 @@ class CoherentStokesProcessing(): ...@@ -921,6 +918,7 @@ class CoherentStokesProcessing():
print_user_warning() print_user_warning()
return self.__pyxb_rtprocessing return self.__pyxb_rtprocessing
# This is identical to coherent stokes. Redundancy already in the SIP schema... # This is identical to coherent stokes. Redundancy already in the SIP schema...
class IncoherentStokesProcessing(): class IncoherentStokesProcessing():
def __init__(self, def __init__(self,
...@@ -968,6 +966,7 @@ class IncoherentStokesProcessing(): ...@@ -968,6 +966,7 @@ class IncoherentStokesProcessing():
print_user_warning() print_user_warning()
return self.__pyxb_rtprocessing return self.__pyxb_rtprocessing
class FlysEyeProcessing(): class FlysEyeProcessing():
def __init__(self, def __init__(self,
rawsamplingtime, rawsamplingtime,
...@@ -982,7 +981,6 @@ class FlysEyeProcessing(): ...@@ -982,7 +981,6 @@ class FlysEyeProcessing():
processingtype="Fly's Eye", processingtype="Fly's Eye",
): ):
__channelwidth = None __channelwidth = None
if channelwidth_frequency and channelwidth_frequencyunit: if channelwidth_frequency and channelwidth_frequencyunit:
__channelwidth = ltasip.Frequency(channelwidth_frequency, units=channelwidth_frequencyunit) __channelwidth = ltasip.Frequency(channelwidth_frequency, units=channelwidth_frequencyunit)
...@@ -999,19 +997,18 @@ class FlysEyeProcessing(): ...@@ -999,19 +997,18 @@ class FlysEyeProcessing():
# Somehow this does not work in the constructor: # Somehow this does not work in the constructor:
self.__pyxb_rtprocessing.channelwidth = __channelwidth self.__pyxb_rtprocessing.channelwidth = __channelwidth
def _get_pyxb_rtprocessing(self, suppress_warning=False): def _get_pyxb_rtprocessing(self, suppress_warning=False):
if not suppress_warning: if not suppress_warning:
print_user_warning() print_user_warning()
return self.__pyxb_rtprocessing return self.__pyxb_rtprocessing
class NonStandardProcessing(): class NonStandardProcessing():
def __init__(self, def __init__(self,
channelwidth_frequency, channelwidth_frequency,
channelwidth_frequencyunit, channelwidth_frequencyunit,
channelspersubband, channelspersubband,
processingtype="Non Standard"): processingtype="Non Standard"):
self.__pyxb_rtprocessing = ltasip.NonStandard( self.__pyxb_rtprocessing = ltasip.NonStandard(
channelsPerSubband=channelspersubband, channelsPerSubband=channelspersubband,
processingType=processingtype, processingType=processingtype,
...@@ -1054,12 +1051,12 @@ class ProcessMap(): ...@@ -1054,12 +1051,12 @@ class ProcessMap():
def get_dict(self): def get_dict(self):
return self.process_map return self.process_map
class ProcessRelation(): class ProcessRelation():
def __init__(self, def __init__(self,
identifier, identifier,
type="GroupID" type="GroupID"
): ):
self.__pyxb_processrelation = ltasip.ProcessRelation( self.__pyxb_processrelation = ltasip.ProcessRelation(
relationType=ltasip.ProcessRelationType(type), relationType=ltasip.ProcessRelationType(type),
identifier=identifier._get_pyxb_identifier(suppress_warning=True) identifier=identifier._get_pyxb_identifier(suppress_warning=True)
...@@ -1081,7 +1078,6 @@ class SimpleProcess(): ...@@ -1081,7 +1078,6 @@ class SimpleProcess():
return self.pyxb_process return self.pyxb_process
# ######## # ########
# Others: # Others:
...@@ -1093,7 +1089,6 @@ class PointingRaDec(): ...@@ -1093,7 +1089,6 @@ class PointingRaDec():
dec_angle, dec_angle,
dec_angleunit, dec_angleunit,
equinox): equinox):
self.__pyxb_pointing = ltasip.Pointing( self.__pyxb_pointing = ltasip.Pointing(
rightAscension=ltasip.Angle(ra_angle, units=ra_angleunit), rightAscension=ltasip.Angle(ra_angle, units=ra_angleunit),
declination=ltasip.Angle(dec_angle, units=dec_angleunit), declination=ltasip.Angle(dec_angle, units=dec_angleunit),
...@@ -1113,7 +1108,6 @@ class PointingAltAz(): ...@@ -1113,7 +1108,6 @@ class PointingAltAz():
alt_angle, alt_angle,
alt_angleunit, alt_angleunit,
equinox): equinox):
self.__pyxb_pointing = ltasip.Pointing( self.__pyxb_pointing = ltasip.Pointing(
azimuth=ltasip.Angle(az_angle, units=az_angleunit), azimuth=ltasip.Angle(az_angle, units=az_angleunit),
altitude=ltasip.Angle(alt_angle, units=alt_angleunit), altitude=ltasip.Angle(alt_angle, units=alt_angleunit),
...@@ -1134,7 +1128,6 @@ class LinearAxis(): ...@@ -1134,7 +1128,6 @@ class LinearAxis():
increment, increment,
referencepixel, referencepixel,
referencevalue): referencevalue):
self.__pyxb_axis = ltasip.LinearAxis( self.__pyxb_axis = ltasip.LinearAxis(
number=number, number=number,
name=name, name=name,
...@@ -1144,6 +1137,7 @@ class LinearAxis(): ...@@ -1144,6 +1137,7 @@ class LinearAxis():
referencePixel=referencepixel, referencePixel=referencepixel,
referenceValue=referencevalue referenceValue=referencevalue
) )
def _get_pyxb_axis(self, suppress_warning=False): def _get_pyxb_axis(self, suppress_warning=False):
if not suppress_warning: if not suppress_warning:
print_user_warning() print_user_warning()
...@@ -1157,7 +1151,6 @@ class TabularAxis(): ...@@ -1157,7 +1151,6 @@ class TabularAxis():
units, units,
length length
): ):
self.__pyxb_axis = ltasip.TabularAxis( self.__pyxb_axis = ltasip.TabularAxis(
number=number, number=number,
name=name, name=name,
...@@ -1196,14 +1189,14 @@ class SubArrayPointing(): ...@@ -1196,14 +1189,14 @@ class SubArrayPointing():
__relations.append(rel._get_pyxb_processrelation(suppress_warning=True)) __relations.append(rel._get_pyxb_processrelation(suppress_warning=True))
__processing = None __processing = None
for processing in [correlatorprocessing, coherentstokesprocessing, incoherentstokesprocessing, flyseyeprocessing, nonstandardprocessing]: for processing in [correlatorprocessing, coherentstokesprocessing, incoherentstokesprocessing,
flyseyeprocessing, nonstandardprocessing]:
if processing: if processing:
if __processing is None: if __processing is None:
__processing = ltasip.Processing() __processing = ltasip.Processing()
__processing.append(processing._get_pyxb_rtprocessing(suppress_warning=True) __processing.append(processing._get_pyxb_rtprocessing(suppress_warning=True)
) )
self.__pyxb_subarraypointing = ltasip.SubArrayPointing( self.__pyxb_subarraypointing = ltasip.SubArrayPointing(
pointing=pointing._get_pyxb_pointing(suppress_warning=True), pointing=pointing._get_pyxb_pointing(suppress_warning=True),
beamNumber=beamnumber, beamNumber=beamnumber,
...@@ -1290,7 +1283,8 @@ class Observation(): ...@@ -1290,7 +1283,8 @@ class Observation():
# Somehow this does not work in the constructor: # Somehow this does not work in the constructor:
if channelwidth_frequency and channelwidth_frequencyunit: if channelwidth_frequency and channelwidth_frequencyunit:
self.__pyxb_observation.channelwidth=ltasip.Frequency(channelwidth_frequency, units=channelwidth_frequencyunit), self.__pyxb_observation.channelwidth = ltasip.Frequency(channelwidth_frequency,
units=channelwidth_frequencyunit),
def _get_pyxb_observation(self, suppress_warning=False): def _get_pyxb_observation(self, suppress_warning=False):
if not suppress_warning: if not suppress_warning:
...@@ -1298,8 +1292,6 @@ class Observation(): ...@@ -1298,8 +1292,6 @@ class Observation():
return self.__pyxb_observation return self.__pyxb_observation
# ############################################################################################# # #############################################################################################
# ============ # ============
...@@ -1369,7 +1361,6 @@ class Sip(object): ...@@ -1369,7 +1361,6 @@ class Sip(object):
print_user_warning() print_user_warning()
self.__sip = pyxb_sip self.__sip = pyxb_sip
# ------------- # -------------
# Optional additions # Optional additions
# --- # ---
...@@ -1382,12 +1373,10 @@ class Sip(object): ...@@ -1382,12 +1373,10 @@ class Sip(object):
self.__sip.observation.append(observation._get_pyxb_observation(suppress_warning=True)) self.__sip.observation.append(observation._get_pyxb_observation(suppress_warning=True))
return self.get_prettyxml() return self.get_prettyxml()
def add_pipelinerun(self, pipeline): def add_pipelinerun(self, pipeline):
self.__sip.pipelineRun.append(pipeline._get_pyxb_pipeline(suppress_warning=True)) self.__sip.pipelineRun.append(pipeline._get_pyxb_pipeline(suppress_warning=True))
return self.get_prettyxml() return self.get_prettyxml()
def add_unspecifiedprocess(self, def add_unspecifiedprocess(self,
observingmode, observingmode,
description, description,
...@@ -1403,7 +1392,6 @@ class Sip(object): ...@@ -1403,7 +1392,6 @@ class Sip(object):
return self.get_prettyxml() return self.get_prettyxml()
def add_parset(self, def add_parset(self,
identifier, identifier,
contents): contents):
...@@ -1417,29 +1405,37 @@ class Sip(object): ...@@ -1417,29 +1405,37 @@ class Sip(object):
def add_related_dataproduct_with_history(self, relateddataproduct_sip): def add_related_dataproduct_with_history(self, relateddataproduct_sip):
# add the dataproduct described by the SIP (if not there) # add the dataproduct described by the SIP (if not there)
if not any(x.dataProductIdentifier.identifier == relateddataproduct_sip.__sip.dataProduct.dataProductIdentifier.identifier for x in self.__sip.relatedDataProduct): if not any(
x.dataProductIdentifier.identifier == relateddataproduct_sip.__sip.dataProduct.dataProductIdentifier.identifier
for x in self.__sip.relatedDataProduct):
self.__sip.relatedDataProduct.append(relateddataproduct_sip.__sip.dataProduct) self.__sip.relatedDataProduct.append(relateddataproduct_sip.__sip.dataProduct)
else: else:
print("WARNING: There already exists a dataproduct with id", relateddataproduct_sip.__sip.dataProduct.dataProductIdentifier.identifier," - Will try to add any new related items anyway.") print("WARNING: There already exists a dataproduct with id",
relateddataproduct_sip.__sip.dataProduct.dataProductIdentifier.identifier,
" - Will try to add any new related items anyway.")
if relateddataproduct_sip.__sip.relatedDataProduct: if relateddataproduct_sip.__sip.relatedDataProduct:
# add related dataproducts (if not there already) # add related dataproducts (if not there already)
for dp in relateddataproduct_sip.__sip.relatedDataProduct: for dp in relateddataproduct_sip.__sip.relatedDataProduct:
if not any(x.dataProductIdentifier.identifier == dp.dataProductIdentifier.identifier for x in self.__sip.relatedDataProduct): if not any(x.dataProductIdentifier.identifier == dp.dataProductIdentifier.identifier for x in
self.__sip.relatedDataProduct):
self.__sip.relatedDataProduct.append(dp) self.__sip.relatedDataProduct.append(dp)
if relateddataproduct_sip.__sip.observation: if relateddataproduct_sip.__sip.observation:
# add related dataproducts (if not there already) # add related dataproducts (if not there already)
for obs in relateddataproduct_sip.__sip.observation: for obs in relateddataproduct_sip.__sip.observation:
if not any(x.processIdentifier.identifier == obs.processIdentifier.identifier for x in self.__sip.observation): if not any(x.processIdentifier.identifier == obs.processIdentifier.identifier for x in
self.__sip.observation):
self.__sip.observation.append(obs) self.__sip.observation.append(obs)
if relateddataproduct_sip.__sip.pipelineRun: if relateddataproduct_sip.__sip.pipelineRun:
# add related pipelineruns (if not there already) # add related pipelineruns (if not there already)
for pipe in relateddataproduct_sip.__sip.pipelineRun: for pipe in relateddataproduct_sip.__sip.pipelineRun:
if not any(x.processIdentifier.identifier == pipe.processIdentifier.identifier for x in self.__sip.pipelineRun): if not any(x.processIdentifier.identifier == pipe.processIdentifier.identifier for x in
self.__sip.pipelineRun):
self.__sip.pipelineRun.append(pipe) self.__sip.pipelineRun.append(pipe)
if relateddataproduct_sip.__sip.unspecifiedProcess: if relateddataproduct_sip.__sip.unspecifiedProcess:
# add related unspecified processes (if not there already) # add related unspecified processes (if not there already)
for unspec in relateddataproduct_sip.__sip.unspecifiedProcess: for unspec in relateddataproduct_sip.__sip.unspecifiedProcess:
if not any(x.processIdentifier.identifier == unspec.processIdentifier.identifier for x in self.__sip.unspecifiedProcess): if not any(x.processIdentifier.identifier == unspec.processIdentifier.identifier for x in
self.__sip.unspecifiedProcess):
self.__sip.unspecifiedProcess.append(unspec) self.__sip.unspecifiedProcess.append(unspec)
if relateddataproduct_sip.__sip.parset: if relateddataproduct_sip.__sip.parset:
# add related parsets (if not there already) # add related parsets (if not there already)
...@@ -1448,7 +1444,6 @@ class Sip(object): ...@@ -1448,7 +1444,6 @@ class Sip(object):
self.__sip.parset.append(par) self.__sip.parset.append(par)
return self.get_prettyxml() return self.get_prettyxml()
def get_dataproduct_identifier(self): def get_dataproduct_identifier(self):
""" """
Get the identifier of the dataproduct that is described by this Sip, e.g. for reference by your pipeline run.. Get the identifier of the dataproduct that is described by this Sip, e.g. for reference by your pipeline run..
...@@ -1483,9 +1478,7 @@ class Sip(object): ...@@ -1483,9 +1478,7 @@ class Sip(object):
def prettyprint(self): def prettyprint(self):
print(self.get_prettyxml()) print(self.get_prettyxml())
def save_to_file(self, path): def save_to_file(self, path):
path = os.path.expanduser(path) path = os.path.expanduser(path)
with open(path, 'w+') as f: with open(path, 'w+') as f:
f.write(self.get_prettyxml()) f.write(self.get_prettyxml())
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment