Skip to content

Commit

Permalink
feat: display info box
Browse files Browse the repository at this point in the history
  • Loading branch information
Lan Le committed Jun 11, 2024
1 parent c4d7ae7 commit 868bc86
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions chem_spectra/lib/composer/ni.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,10 @@ def __gen_header_user_input_meta_data(self):
melting_point = dsc_meta_data.get('meltingPoint', '')
tg_value = dsc_meta_data.get('tg', '')
else:
melting_point = self.core.dic.get('MELTINGPOINT', '')
tg_value = self.core.dic.get('TG', '')
melting_point_arr = self.core.dic.get('MELTINGPOINT', [''])
tg_value_arr = self.core.dic.get('TG', [''])
melting_point = melting_point_arr[0]
tg_value = tg_value_arr[0]
return [
f'##MELTINGPOINT={melting_point}\n',
f'##TG={tg_value}\n'
Expand Down Expand Up @@ -528,16 +530,32 @@ def tf_img(self):


def __generate_info_box(self, plotlib):
if not self.core.is_sec:
if not (self.core.is_sec or self.core.is_dsc):
return
core_dic = self.core.dic
sec_data_key = ['MN', 'MW', 'MP', 'D']
result = []
for key in sec_data_key:
dic_value = core_dic.get(key, [])
key_str = f"{key}={dic_value[0]}" if len(dic_value) > 0 else None
if key_str is not None:
result.append(key_str)
if self.core.is_sec:
sec_data_key = ['MN', 'MW', 'MP', 'D']
for key in sec_data_key:
dic_value = core_dic.get(key, [])
key_str = f"{key}={dic_value[0]}" if len(dic_value) > 0 else None
if key_str is not None:
result.append(key_str)
else:
dsc_meta_data = self.core.params.get('dsc_meta_data', None)
melting_point, tg_value = '', ''
if dsc_meta_data is not None:
melting_point = dsc_meta_data.get('meltingPoint', '')
tg_value = dsc_meta_data.get('tg', '')
else:
melting_point_arr = self.core.dic.get('MELTINGPOINT', [''])
tg_value_arr = self.core.dic.get('TG', [''])
melting_point = melting_point_arr[0]
tg_value = tg_value_arr[0]

melting_point_str = f"MELTING POINT={melting_point}"
tg_str = f"TG={tg_value}"
result.extend([melting_point_str, tg_str])

info_str = '\n'.join(result)
props = dict(boxstyle='round', facecolor='wheat', alpha=0.5)
Expand Down

0 comments on commit 868bc86

Please sign in to comment.