public:lta_tricks

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
public:lta_tricks [2020-04-10 10:01] – [AstroWise Python Interface] Reinoud Bokhorstpublic:lta_tricks [2020-04-10 10:04] – [Examples] Reinoud Bokhorst
Line 302: Line 302:
 </code> </code>
  
-== Example; query public data ==+=== Example; query public data ===
  
 Querying public data in projects you are not member of. First set project ALL, then construct a query and optionally limit the query to a certain project : Querying public data in projects you are not member of. First set project ALL, then construct a query and optionally limit the query to a certain project :
Line 314: Line 314:
 </code> </code>
  
 +=== Example; get release dates ===
 +
 +<code python>
 +from awlofar.main.aweimports import Observation, PipelineRun, DataProduct
 +from common.database.Context import context
 +
 +project = 'LC2_035'
 +
 +# Query for private data of the project, you must be member of the project
 +private_data = True
 +
 +# To see private data of this project, you must be member of this project
 +if private_data :
 +    context.set_project(project)
 +    if project != context.get_current_project().name:
 +        raise Exception("You are not member of project %s" % project)
 +
 +# Observations
 +query_observations = Observation.select_all().project_only(project)
 +for observation in query_observations :
 +    print("Querying ObservationID %s, %s" % (observation.observationId, observation.releaseDate))
 +
 +# Pipelines
 +query_pipelines = PipelineRun.select_all().project_only(project)
 +for pipeline in query_pipelines :
 +    print("Pipeline: %s, %s, %s" % (type(pipeline).__name__, pipeline.pipelineName, pipeline.releaseDate))
 +
 +
 +# Data products
 +query_products = DataProduct.select_all().project_only(project)
 +query_products &= DataProduct.isValid == 1
 +for product in query_products :
 +    print("Product: %s, %s, %s, %s" % (product.dataProductIdentifier, product.dataProductIdentifierSource, product.dataProductType, product.releaseDate))
 +</code>
 ===== Python Module for Staging ===== ===== Python Module for Staging =====
  
  • Last modified: 2023-07-17 08:51
  • by Robbie Luijben