Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous 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 [2023-07-17 08:51] (current) – Robbie Luijben | ||
---|---|---|---|
Line 51: | Line 51: | ||
There is a server that gives the option to run your own queries on the database [[https:// | There is a server that gives the option to run your own queries on the database [[https:// | ||
- | A useful query might be this one, that gives you all files for a certain Obs Id (SAS VIC tree ID).< | + | A useful query might be this one, that gives you all files for a certain Obs Id (SAS VIC tree ID). |
+ | < | ||
SELECT fo.URI, dp." | SELECT fo.URI, dp." | ||
| | ||
Line 61: | Line 63: | ||
AND fo.data_object = dp." | AND fo.data_object = dp." | ||
AND dp." | AND dp." | ||
+ | |||
</ | </ | ||
Line 77: | Line 80: | ||
AND fo.data_object = dp." | AND fo.data_object = dp." | ||
AND dp." | AND dp." | ||
+ | |||
</ | </ | ||
Line 85: | Line 89: | ||
Once you have installed the client, set up your user name and password. These are the same as for MoM. Remember that this is just a different interface to the LTA catalogue: you will need the same credentials as for the web interface. | Once you have installed the client, set up your user name and password. These are the same as for MoM. Remember that this is just a different interface to the LTA catalogue: you will need the same credentials as for the web interface. | ||
- | After installing the LTA client, the file .awe/ | + | After installing the LTA client, the file .awe/ |
+ | < | ||
[global] | [global] | ||
database_user | database_user | ||
database_password | database_password | ||
+ | |||
</ | </ | ||
Line 120: | Line 127: | ||
pprint(result) | pprint(result) | ||
+ | |||
</ | </ | ||
Line 134: | Line 142: | ||
Pointing found RA 95.561458 DEC 24.584056 | Pointing found RA 95.561458 DEC 24.584056 | ||
..etc.. | ..etc.. | ||
+ | |||
</ | </ | ||
Line 140: | Line 149: | ||
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 151: | Line 160: | ||
Observation | Observation | ||
from awlofar.toolbox.LtaStager import LtaStager, LtaStagerError | from awlofar.toolbox.LtaStager import LtaStager, LtaStagerError | ||
+ | |||
+ | |||
</ | </ | ||
The lines above must be added to each of the scripts below for these to work. | The lines above must be added to each of the scripts below for these to work. | ||
- | This simple | + | === Ex: get staging URI's === |
+ | |||
+ | This script will allow you to find all data within a single project, for example LC2_035. Please change the project name to the code of a project of yours. If you also want to stage the data you found, just set the do_stage variable to True. Be careful with how many files you stage and what size they have: the same limits as for the web interface apply here. | ||
<code python> | <code python> | ||
Line 195: | Line 208: | ||
stager = LtaStager() | stager = LtaStager() | ||
stager.stage_uris(uris) | stager.stage_uris(uris) | ||
+ | |||
</ | </ | ||
+ | |||
+ | === Ex: filter on subbands === | ||
The following script will find subbands 301 and 302 for all targets within two different projects. | The following script will find subbands 301 and 302 for all targets within two different projects. | ||
Line 251: | Line 267: | ||
for project in (project1, project2) : | for project in (project1, project2) : | ||
stager.stage_uris(uris[project]) | stager.stage_uris(uris[project]) | ||
+ | |||
+ | |||
</ | </ | ||
+ | |||
+ | === Ex: filter on frequency and observation date === | ||
Here, we find data between freq1 and freq2 taken within one project between day1 and day2 | Here, we find data between freq1 and freq2 taken within one project between day1 and day2 | ||
Line 299: | Line 319: | ||
stager = LtaStager() | stager = LtaStager() | ||
stager.stage_uris(uris) | stager.stage_uris(uris) | ||
+ | |||
</ | </ | ||
- | == Example; | + | === Ex: 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 312: | Line 333: | ||
print(len(query)) | print(len(query)) | ||
# 1800 | # 1800 | ||
+ | |||
+ | |||
</ | </ | ||
- | ===== Python Module | + | === Ex: get release dates === |
+ | |||
+ | <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 | ||
+ | |||
+ | # 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 | ||
+ | for observation in query_observations : | ||
+ | print(" | ||
+ | |||
+ | # Pipelines | ||
+ | query_pipelines | ||
+ | for pipeline in query_pipelines : | ||
+ | print(" | ||
+ | |||
+ | # Data products | ||
+ | query_products | ||
+ | query_products &= DataProduct.isValid == 1 | ||
+ | for product in query_products : | ||
+ | print(" | ||
- | The python interaction with the LTA catalog can be complemented with the use of a specific module developed to give users more control over their staging requests. | ||
- | **Alternatively to the .awe/ | ||
- | user=XXX | ||
- | password=YYY | ||
</ | </ | ||
+ | |||
+ | ===== Python Module for Staging ===== | ||
+ | |||
+ | The python interaction with the LTA catalog can be complemented with the use of a specific module developed to give users more control over their staging requests. | ||
+ | |||
+ | Current released version 2.0 ([[http:// | ||
+ | |||
+ | * User documentation for __//stageit //__ can be found at: [[https:// | ||
+ | * Version 2.0 release can be found at: [[https:// | ||
+ | |||
+ | ==== Version 2.0 usage notes ==== | ||
+ | |||
+ | The module is made available [[http:// | ||
+ | |||
+ | __Notes:__ | ||
+ | |||
+ | * You need an access token to the stageit api. Please refer to the user guide linked above to sign up and login to stageit. After logging in, a token can be obtained in one of two ways: | ||
+ | * Visit [[https:// | ||
+ | * From anywhere in the application, | ||
+ | * The token is valid indefinitely. Requesting a token multiple times will yield the same token. | ||
+ | * Make sure the token is available in your ~/ | ||
+ | * api_token=YOUR_TOKEN_HERE | ||
+ | * remove the old username and password from the '' | ||
+ | * The script is Python2 compatible, there is a Dockerfile available for Python2 testing in '' | ||
+ | * The requests library is a required dependency. If you care about Python2 compatability, | ||
+ | |||
+ | Also note that some functions are not supported in the new LTA stager. The states that a request can be in have been simplified. As such, there is no need for these functions anymore. Upon use, they will display an error stating that the function is deprecated. Please look at the '' | ||
+ | |||
+ | ==== Functionality ==== | ||
For a description of what the user can do, we list here the functions that are available. | For a description of what the user can do, we list here the functions that are available. | ||
Line 340: | Line 419: | ||
Below is an example of how to use this: | Below is an example of how to use this: | ||
- | + | < | |
- | < | + | > python |
Python 2.7.10 (default, Oct 23 2015, 19:19:21) | Python 2.7.10 (default, Oct 23 2015, 19:19:21) | ||
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin | [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin | ||
Line 350: | Line 429: | ||
+ 12227 | + 12227 | ||
- | - File count -> 100 | + | - File count |
- Files done -> 40 | - Files done -> 40 | ||
- Flagged abort -> false | - Flagged abort -> false | ||
Line 357: | Line 436: | ||
- Status | - Status | ||
- User id -> 1919 | - User id -> 1919 | ||
+ | |||
</ | </ | ||