from dkrz_forms import form_widgets
form_widgets.show_status('form-submission')

"""
Explanation: ESGF replication request form
This form is intended to request data to be replicated from other ESGF nodes to be made
locally available in the DKRZ CMIP data pool.
The specification of a requested data collection is based on the search facets describing the data collection. These facets correspond directly to the search categories you use to find data  in one of the ESGF portals (e.g. https://esgf-data.dkrz.de/).
The specification is based on "selection files", which are then used by the synda ESGF download application. For details please see https://github.com/Prodiguer/synda/blob/master/sdt/doc/selection_file.md
- a set of example selection files is accessible at: https://github.com/Prodiguer/synda/tree/master/sdt/selection/sample
End of explanation
"""


MY_LAST_NAME = "...."   # e.gl MY_LAST_NAME = "schulz" 
#-------------------------------------------------
from dkrz_forms import form_handler, form_widgets
form_info = form_widgets.check_pwd(MY_LAST_NAME)
sf = form_handler.init_form(form_info)
form = sf.sub.entity_out.form_info

"""
Explanation: Please provide your last name and the password for this form
End of explanation
"""


%%writefile selection/......txt  


%%writefile selection/......txt 


"""
Explanation: Edit and store your replica selection file(s)
Example selection file
 %%writefile test1.txt
 project="CMIP5"
 model="CNRM-CM5 CSIRO-Mk3-6-0"
 experiment="historical amip"
 ensemble="r1i1p1"
 variable[atmos][mon]="tasmin tas psl"
 variable[ocean][fx]="areacello sftof"
 variable[land][mon]="mrsos,nppRoot,nep"
 variable[seaIce][mon]="sic evap"
 variable[ocnBgchem][mon]="dissic fbddtalk"

-->this generates and stores a selection file named "test1.txt"
Provide your selection files below
End of explanation
"""


%%bash 

synda dump -s .....txt
#synda install -s example_selection_file_tst.txt # change file name accordingly

%%bash
synda dump -h

"""
Explanation: Check your selection file
using the cells below you can check the coorectness of your selection files
it also privides you information on the amount of data to be transfered
End of explanation
"""


sf.ticket_id = "...."  # Ticket Number in DKRZ RT ticketing system

sf.selection_files = ["...."]  # Provide names of selection files specified in next section

##to be completed

"""
Explanation: Provide the ticket number for the replica request sent to esgf-replication@dkrz.de
End of explanation
"""


form_handler.save_form(sf,"..my comment..") # edit my comment info 

"""
Explanation: Save your form
your form will be stored (the form name consists of your last name plut your keyword)
End of explanation
"""


form_handler.email_form_info(sf)
form_handler.form_submission(sf)

"""
Explanation: officially submit your form
the form will be submitted to the DKRZ team to process
you also receive a confirmation email with a reference to your online form for future modifications
End of explanation
"""


%%bash 

# synda dump tas GFDL-ESM2M -F line -f -C size,filenam
synda variable tas
# synda search cmip5 MOHC HadGEM2-A amip4
# synda search cmip5 mon atmos -l 1000xCO2 mon atmos Amon r1i1p1

%%bash 

synda -h

"""
Explanation: Example synda calls
Explore Metadata
example synda calls to search and explore metadata
End of explanation
"""


