Commit cda41165 authored by Wei Chengliang's avatar Wei Chengliang
Browse files

format codestyle-PEP8

parent 4a0ff3ab
Pipeline #7335 failed with stage
in 0 seconds
......@@ -10,13 +10,13 @@ key_type_map = {
'obs_type_code': str,
'obs_id': str,
'run_chips': list,
'call_sequence':{
'scie_obs':{
'call_sequence': {
'scie_obs': {
'shutter_effect': bool,
'flat_fielding': bool,
'field_dist': bool,
},
'sky_background':{
'sky_background': {
'shutter_effect': bool,
'flat_fielding': bool,
'enable_straylight_model': bool,
......@@ -24,35 +24,37 @@ key_type_map = {
'flat_level_filt': None,
},
'PRNU_effect': {},
'cosmic_rays':{
'cosmic_rays': {
'save_cosmic_img': bool,
},
'poisson_and_dark':{
'poisson_and_dark': {
'add_dark': bool,
},
'bright_fatter': {},
'detector_defects':{
'detector_defects': {
'hot_pixels': bool,
'dead_pixels': bool,
'bad_columns': bool,
},
'nonlinearity': {},
'blooming': {},
'prescan_overscan':{
'prescan_overscan': {
'add_dark': bool,
},
'bias':{
'bias': {
'bias_16channel': bool,
},
'readout_noise': {},
'gain':{
'gain': {
'gain_16channel': bool,
},
'quantization_and_output':{
'quantization_and_output': {
'format_output': bool,
},
},
}
def convert_dict_values(d, key_type_map):
for key, value in d.items():
if isinstance(value, dict):
......@@ -75,16 +77,17 @@ def convert_dict_values(d, key_type_map):
d[key] = None
def load_yaml():
with open('templates/obs_config_SCI.yaml', 'r') as file:
return yaml.safe_load(file)
def save_yaml(data):
convert_dict_values(data, key_type_map)
with open('config_reset/obs_config_SCI_reset.yaml', 'w') as file:
yaml.dump(data, file, default_flow_style=False, sort_keys=False)
def render_form(data, parent_key=''):
form_html = ''
for key, value in data.items():
......@@ -96,6 +99,7 @@ def render_form(data, parent_key=''):
form_html += f"<input type='text' id='{full_key}' name='{full_key}' value='{value}'><br>"
return form_html
@app.route('/', methods=['GET', 'POST'])
def index():
if request.method == 'POST':
......@@ -113,6 +117,6 @@ def index():
form_html = render_form(data)
return render_template('index_obs.html', form_html=form_html)
if __name__ == '__main__':
app.run(debug=True)
......@@ -9,16 +9,16 @@ key_type_map = {
'run_name': str,
'project_cycle': int,
'run_counter': int,
'run_option':{
'run_option': {
'out_cat_only': bool,
},
'catalog_options':{
'input_path':{
'catalog_options': {
'input_path': {
'cat_dir': str,
'star_cat': str,
'galaxy_cat': str,
},
'SED_templates_path':{
'SED_templates_path': {
'star_SED': str,
'galaxy_SED': str,
'AGN_SED': str,
......@@ -29,7 +29,7 @@ key_type_map = {
'enable_mw_ext_gal': bool,
'planck_ebv_map':str,
},
'obs_setting':{
'obs_setting': {
'pointing_file': str,
'obs_config_file': str,
'run_pointings': list,
......@@ -38,22 +38,22 @@ key_type_map = {
'mag_sat_margin': float,
'mag_lim_margin': float,
},
'psf_setting':{
'psf_setting': {
'psf_model': str,
'psf_pho_dir': str,
'psf_sls_dir': str,
},
'shear_setting':{
'shear_setting': {
'shear_type': str,
'reduced_g1': float,
'reduced_g2': float,
},
'output_setting':{
'output_setting': {
'output_format': str,
'shutter_output': bool,
'prnu_output': bool,
},
'random_seeds':{
'random_seeds': {
'seed_poisson': int,
'seed_CR': int,
'seed_flat': int,
......@@ -66,6 +66,8 @@ key_type_map = {
'seed_readout': int,
},
}
def convert_dict_values(d, key_type_map):
for key, value in d.items():
if isinstance(value, dict):
......@@ -85,15 +87,18 @@ def convert_dict_values(d, key_type_map):
if key_type_map[key] is list:
d[key] = ast.literal_eval(value)
def load_yaml():
with open('templates/config_overall.yaml', 'r') as file:
return yaml.safe_load(file)
def save_yaml(data):
convert_dict_values(data, key_type_map)
with open('config_reset/config_overall_reset.yaml', 'w') as file:
yaml.dump(data, file, default_flow_style=False, sort_keys=False)
def render_form(data, parent_key=''):
form_html = ''
for key, value in data.items():
......@@ -105,6 +110,7 @@ def render_form(data, parent_key=''):
form_html += f"<input type='text' id='{full_key}' name='{full_key}' value='{value}'><br>"
return form_html
@app.route('/', methods=['GET', 'POST'])
def index():
if request.method == 'POST':
......@@ -122,6 +128,6 @@ def index():
form_html = render_form(data)
return render_template('index_overall.html', form_html=form_html)
if __name__ == '__main__':
app.run(debug=True)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment