Skip to content
Snippets Groups Projects
Commit 4fab744f authored by Carlo Ferrigno's avatar Carlo Ferrigno
Browse files

Add use_jemx2 optional parameter

parent 7a19073e
No related branches found
No related tags found
No related merge requests found
%% Cell type:code id:cd05caa6 tags:parameters
``` python
import os,sys
token=''
# This defines the range of revlutions to process, default is the last 10
rev_num_indicator = 0
force_reprocessing = True
data_processing = 'NRT'
host_type = 'staging'
use_jemx2 = False
notebooks_folder = os.getcwd()
```
%% Cell type:code id:0924c9db tags:
``` python
import pandas as pd
import requests
from bs4 import BeautifulSoup
import numpy as np
import os,sys
import oda_integral_wrapper.wrapper
import yaml
import json
import papermill as pm
from datetime import datetime
from importlib import reload
```
%% Cell type:code id:374f2a15 tags:
``` python
import logging
#logging.getLogger().setLevel(logging.WARNING)
logging.getLogger().setLevel(logging.INFO) #for more verbose logging
logger = logging.getLogger('').addHandler(logging.StreamHandler())
```
%% Cell type:code id:d1b6bb71 tags:
``` python
import oda_api.token
print(token)
if token is None or token == '':
token = oda_api.token.discover_token()
# extend token lifetime
from oda_api.api import DispatcherAPI
disp = DispatcherAPI(url='https://www.astro.unige.ch/mmoda/dispatch-data')
token = disp.refresh_token(token, write_token=True)
oda_api.token.decode_oda_token(token)
```
%% Cell type:code id:c626a24b tags:
``` python
import oda_integral_wrapper.itime as itime
if rev_num_indicator <= 0:
now = itime.now()
rev_num = int(now.REVNUM) + rev_num_indicator
else:
rev_num = int(rev_num_indicator)
```
%% Cell type:markdown id:6ba77738 tags:
## Actual processing using papermill
%% Cell type:code id:b021fee7 tags:
``` python
failed = False
now = datetime.now().strftime("%Y_%m_%d_%H_%M_%S")
par_dict = {
'rev_num' : rev_num,
'host_type' : host_type,
'token': token,
'data_version': data_processing,
'use_jemx2': False,
'use_jemx2': use_jemx2,
'notebooks_folder': notebooks_folder,
'batch_run' : True
}
print(f"Running ProcessNRTRevolutions notebook for revolution number: {rev_num}")
try:
print(f"Processing Mosaics for revolution number: {rev_num}")
mosaics_notebook_path = os.path.join(notebooks_folder,"Generic Revolution Mosaics.ipynb")
print(f"Mosaics notebook path: {mosaics_notebook_path}")
output_mosaics_notebook_path = os.path.join(notebooks_folder, f"out/Generic Revolution Mosaics_output_{rev_num}_{now}.ipynb")
print(f"Output Mosaics notebook path: {output_mosaics_notebook_path}")
nb_mosaics_execution = pm.execute_notebook(
mosaics_notebook_path,
output_mosaics_notebook_path,
parameters=par_dict,
log_output=True
)
print("Succesfully processed Mosaics for revolution number: %s" %(rev_num))
except:
failed = True
print(f'Mosaics failed for revolution number: {rev_num}')
print('Check ' + f"out/Generic Revolution Mosaics_output_{rev_num}_{now}.ipynb")
if not failed:
try:
print(f"Processing Spectra for revolution number: {rev_num}")
spectra_notebook_path = os.path.join(notebooks_folder,"Generic Revolution Spectra.ipynb")
print(f"Spectra notebook path: {spectra_notebook_path}")
output_spectra_notebook_path = os.path.join(notebooks_folder, f"out/Generic Revolution Spectra_output_{rev_num}_{now}.ipynb")
print(f"Output Spectra notebook path: {output_spectra_notebook_path}")
nb_spectra_execution = pm.execute_notebook(
spectra_notebook_path,
output_spectra_notebook_path,
parameters=par_dict,
log_output=True
)
print(f"Succesfully processed Spectra for revolution number: {rev_num}")
except:
failed = True
print(f'Spectra failed for revolution number: {rev_num}')
print('Check ' + f"out/Generic Revolution Spectra_output_{rev_num}_{now}.ipynb")
try:
print(f"Processing LC for revolution number: {rev_num}")
lc_notebook_path = os.path.join(notebooks_folder, "Generic Revolution LC.ipynb")
print(f"LC notebook path: {lc_notebook_path}")
output_lc_notebook_path = os.path.join(notebooks_folder, f"out/Generic Revolution LC_output_{rev_num}_{now}.ipynb")
print(f"Output LC notebook path: {output_lc_notebook_path}")
nb_lc_execution = pm.execute_notebook(
lc_notebook_path,
output_lc_notebook_path,
parameters=par_dict,
log_output=True
)
print(f"Succesfully processed LC for revolution number: {rev_num}")
except:
failed = True
print(f'Light Curve failed for revolution number: {rev_num}')
print('Check ' + f"out/Generic Revolution LC_output_{rev_num}_{now}.ipynb")
```
%% Cell type:code id:a7435cc1 tags:
``` python
```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment