Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revisionBoth sides next revision | ||
public:lta_tricks [2019-09-20 07:25] – Updated link to LOFAR stager API Python module to point to the ASTRON gitlab repo Thomas Jürges | public:lta_tricks [2020-04-10 10:03] – [Examples] Reinoud Bokhorst | ||
---|---|---|---|
Line 140: | Line 140: | ||
In case of errors, there may be the need to open some port on the firewall at your institution. Specifically, | In case of errors, there may be the need to open some port on the firewall at your institution. Specifically, | ||
- | == Examples == | + | ==== Examples |
Once you have tested that your connection to the catalogue is working, you are ready to browse the archive and stage the data you need. Here we will list a few examples of python scripts that can be used to access the LTA. All of them will need to import some modules: | Once you have tested that your connection to the catalogue is working, you are ready to browse the archive and stage the data you need. Here we will list a few examples of python scripts that can be used to access the LTA. All of them will need to import some modules: | ||
Line 302: | Line 302: | ||
</ | </ | ||
- | == 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: | ||
</ | </ | ||
+ | === Example; get release date for all observations, | ||
+ | |||
+ | <code python> | ||
+ | from awlofar.main.aweimports import Observation, | ||
+ | from common.database.Context import context | ||
+ | |||
+ | project = ' | ||
+ | |||
+ | # 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(" | ||
+ | |||
+ | # Observations | ||
+ | query_observations = Observation.select_all().project_only(project) | ||
+ | for observation in query_observations : | ||
+ | print(" | ||
+ | |||
+ | # Pipelines | ||
+ | query_pipelines = PipelineRun.select_all().project_only(project) | ||
+ | for pipeline in query_pipelines : | ||
+ | print(" | ||
+ | |||
+ | |||
+ | # Data products | ||
+ | query_products = DataProduct.select_all().project_only(project) | ||
+ | query_products &= DataProduct.isValid == 1 | ||
+ | for product in query_products : | ||
+ | print(" | ||
+ | </ | ||
===== Python Module for Staging ===== | ===== Python Module for Staging ===== | ||