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