Skip to content

Commit

Permalink
export g(r) fitting data to agent
Browse files Browse the repository at this point in the history
  • Loading branch information
XPD Operator committed May 10, 2024
1 parent ae01336 commit 077d43f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions scripts/_pdf_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def _no_oxidation_cif(cif_file):



def _pdffit2_CsPbX3(gr_data, cif_list, qmax=20, qdamp=0.031, qbroad=0.032):
def _pdffit2_CsPbX3(gr_data, cif_list, qmax=20, qdamp=0.031, qbroad=0.032, fix_APD=True):

# Initialize the CifParser with the path to your .cif file
# Parse the .cif file
Expand All @@ -46,7 +46,7 @@ def _pdffit2_CsPbX3(gr_data, cif_list, qmax=20, qdamp=0.031, qbroad=0.032):
pf.add_structure(stru)

# set contrains for lattice parameter, ADP
_set_CsPbBr3_constrain(pf)
_set_CsPbBr3_constrain(pf, fix_APD=fix_APD)

# set constrain for data scale
pf.constrain(pf.dscale, '@902')
Expand Down
16 changes: 14 additions & 2 deletions scripts/kafka_consumer_iterate_RM.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@
agent = build_agen2(peak_target=peak_target)


fitting_pdf = True
if fitting_pdf:
pdf_cif_dir = '/home/xf28id2/Documents/ChengHung/pdffit2_example/CsPbBr3/'
cif_list = [os.path.join(pdf_cif_dir, 'CsPbBr3_Orthorhombic.cif')]
gr_data = os.path.join(pdf_cif_dir, 'CsPbBr3.gr')


def print_kafka_messages(beamline_acronym, csv_path=csv_path,
key_height=key_height, height=height, distance=distance,
pump_list=pump_list, sample=sample, precursor_list=precursor_list,
Expand Down Expand Up @@ -244,8 +251,11 @@ def print_message(consumer, doctype, doc,

## obtain phase fraction & particle size from g(r)
if 'scattering' in stream_list:
phase_fraction, particel_size = pc._pdffit2_CsPbX3(gr_data, cif_list, qmax=20, qdamp=0.031, qbroad=0.032)

if fitting_pdf:
phase_fraction, particel_size = pc._pdffit2_CsPbX3(gr_data, cif_list, qmax=20, qdamp=0.031, qbroad=0.032)
pdf_property={'Br_ratio': phase_fraction[0], 'Br_size':particel_size[0]}
else:
pdf_property={'Br_ratio': None, 'Br_size':None}
## remove 'scattering' from stream_list to avoid redundant work in next for loop
stream_list.remove('scattering')

Expand Down Expand Up @@ -375,6 +385,8 @@ def print_message(consumer, doctype, doc,
agent_data = {}

agent_data.update(optical_property)
agent_data.update(pdf_property)

agent_data.update({k:v for k, v in metadata_dic.items() if len(np.atleast_1d(v)) == 1})

agent_data = de._exprot_rate_agent(metadata_dic, rate_label_dic, agent_data)
Expand Down

0 comments on commit 077d43f

Please sign in to comment.