Skip to content

Commit

Permalink
bump version 3.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
BM32ESRF committed Nov 15, 2022
1 parent 6277cab commit 4ee5483
Show file tree
Hide file tree
Showing 11 changed files with 1,652 additions and 1,448 deletions.
1,065 changes: 667 additions & 398 deletions lauetoolsnn/end_to_end_scripts/LaueNN_pyScript_1_or_2phase.ipynb

Large diffs are not rendered by default.

52 changes: 23 additions & 29 deletions lauetoolsnn/end_to_end_scripts/LaueNN_pyScript_1_or_2phase.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
print("LaueNN path is", laueNN_path)

## Load the json of material and extinctions
with open(os.path.join(laueNN_path, 'lauetools\material.json'),'r') as f:
with open(os.path.join(laueNN_path, 'lauetools','material.json'),'r') as f:
dict_Materials = json.load(f)
with open(os.path.join(laueNN_path, 'lauetools\extinction.json'),'r') as f:
with open(os.path.join(laueNN_path, 'lauetools','extinction.json'),'r') as f:
extinction_json = json.load(f)

## Modify the dictionary values to add new entries
Expand All @@ -41,9 +41,9 @@
## verify if extinction is present in CrystalParameters.py file of lauetools (Manually done for now)

## dump the json back with new values
with open(os.path.join(laueNN_path, 'lauetools\material.json'), 'w') as fp:
with open(os.path.join(laueNN_path, 'lauetools','material.json'), 'w') as fp:
json.dump(dict_Materials, fp)
with open(os.path.join(laueNN_path, 'lauetools\extinction.json'), 'w') as fp:
with open(os.path.join(laueNN_path, 'lauetools','extinction.json'), 'w') as fp:
json.dump(extinction_json, fp)

## Verify if the material is added to the library or not;
Expand All @@ -58,7 +58,7 @@
## User Input dictionary with parameters
## In case of only one phase/material, keep same value for material_ and material1_ key
input_params = {
"global_path" : r"C:\Users\purushot\Desktop\LaueNN_script",
"global_path" : os.getcwd(),
"prefix" : "_2phase", ## prefix for the folder to be created for training dataset

"material_": ["GaN", "Si"], ## same key as used in dict_LaueTools
Expand All @@ -79,7 +79,7 @@

"include_small_misorientation": False, ## to include additional data with small angle misorientation
"misorientation": 5, ##only used if "include_small_misorientation" is True
"maximum_angle_to_search":20, ## Angle of radial distribution to reconstruct the histogram (in deg)
"maximum_angle_to_search":90, ## Angle of radial distribution to reconstruct the histogram (in deg)
"step_for_binning" : 0.1, ## bin widht of angular radial distribution in degree

# =============================================================================
Expand All @@ -104,10 +104,10 @@
# =============================================================================
# ## Prediction parameters
# =============================================================================
"experimental_directory": r"D:\some_projects\GaN\BLC12834\NW1",
"experimental_directory": os.getcwd(),
"experimental_prefix": r"nw1_",
"grid_size_x" : 61, ## Grid X and Y limit to generate the simulated dataset (a rectangular scan region)
"grid_size_y" : 61,
"grid_size_x" : 1, ## Grid X and Y limit to generate the simulated dataset (a rectangular scan region)
"grid_size_y" : 2,

# =============================================================================
# ## Prediction Settings
Expand All @@ -132,11 +132,11 @@
# =============================================================================
# # [PEAKSEARCH]
# =============================================================================
"intensity_threshold" : 2,
"boxsize" : 10,
"fit_peaks_gaussian" : 1,
"FitPixelDev" : 15,
"NumberMaxofFits" : 3000,
"intensity_threshold" : 2,## for skimage this is of image standard deviation
"boxsize" : 10,## for skimage this is box size to fit
"fit_peaks_gaussian" : 1,## for skimage this is of no sense
"FitPixelDev" : 15, ## for skimage this is distance between peaks to avoid
"NumberMaxofFits" : 3000,## for skimage this is maximum leastquare attempts before giving up
"mode": "skimage",

# =============================================================================
Expand All @@ -159,9 +159,9 @@
}

generate_dataset = True
train_network = False
write_config_GUI = False
run_prediction = False
train_network = True
write_config_GUI = True
run_prediction = True
prediction_GUI = False
# =============================================================================
# END OF USER INPUT
Expand Down Expand Up @@ -314,7 +314,7 @@
SG1 = input_params["SG"][1]

## read hkl information from a fit file in case too large HKLs
manual_hkl_list=True
manual_hkl_list=False
if manual_hkl_list:
##read from a text file (fit file)
import numpy as np
Expand Down Expand Up @@ -886,7 +886,7 @@
crystal1,
strain_free_parameters] for ii in range(count_global)]

## test single file prediction
## test singel file prediction
# results = new_MP_function(valu12[0])
# best = results[-2][0][0][0]

Expand Down Expand Up @@ -924,14 +924,12 @@
if not os.path.exists(save_directory_):
os.makedirs(save_directory_)

## Numpy pickle data with user defined keys
np.savez_compressed(save_directory_+ "//results.npz",
best_match, mat_global, rotation_matrix, strain_matrix,
strain_matrixs, col, colx, coly, match_rate, files_treated,
lim_x, lim_y, spots_len, iR_pix, fR_pix,
material_, material1_)

## pickle object saving
## intermediate saving of pickle objects with results
with open(save_directory_+ "//results.pickle", "wb") as output_file:
cPickle.dump([best_match, mat_global, rotation_matrix, strain_matrix,
strain_matrixs, col, colx, coly, match_rate, files_treated,
Expand All @@ -947,8 +945,7 @@
radius=10, grain_ang=5, pixel_grain_definition=3)
except:
print("Error with Average orientation and grain index calculation")

## save also the results in HDF5 format

try:
convert_pickle_to_hdf5(save_directory_, files_treated, rotation_matrix, strain_matrix,
strain_matrixs, match_rate, spots_len, iR_pix,
Expand All @@ -957,23 +954,20 @@
except:
print("Error writting H5 file")

## Write prediction statistics
try:
write_prediction_stats(save_directory_, material_, material1_, files_treated,\
lim_x, lim_y, best_match, strain_matrixs, strain_matrix, iR_pix,\
fR_pix, mat_global)
except:
print("Error writting prediction statistics file")

## Write MTEX orientation data

try:
write_MTEXdata(save_directory_, material_, material1_, rotation_matrix,\
lattice_material, lattice_material1, lim_x, lim_y, mat_global,\
input_params["symmetry"][0], input_params["symmetry"][1])
except:
print("Error writting MTEX orientation file")

## Save some images

try:
global_plots(lim_x, lim_y, rotation_matrix, strain_matrix, strain_matrixs,
col, colx, coly, match_rate, mat_global, spots_len,
Expand Down
Loading

0 comments on commit 4ee5483

Please sign in to comment.