Skip to content

Commit

Permalink
plot beam statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
relleums committed Aug 26, 2024
1 parent bc7228a commit 538581b
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 3 deletions.
44 changes: 44 additions & 0 deletions plenoptics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ def run(work_dir, pool=None, logger=None):

logger.info("Make Plots")

logger.info("Plot beam statistics")
pjobs = _plot_beam_statistics_make_jobs(work_dir=work_dir, config=config)
logger.info("{:d} jobs to do".format(len(pjobs)))
pool.map(_run_script_job, pjobs)

logger.info("Plot mirror deformations")
pjobs = _plot_mirror_deformations_make_jobs(
work_dir=work_dir, config=config
Expand Down Expand Up @@ -69,6 +74,45 @@ def run(work_dir, pool=None, logger=None):
logger.info("Done")


def _plot_beam_statistics_make_jobs(work_dir, config=None):
config = utils.config_if_None(work_dir=work_dir, config=config)
jobs = []
for ylim in [False, True]:
ylim_dir = "ylim_based_on_num_channels" if ylim else "ylim_guess"
for colormode_key in config["plot"]["colormodes"]:
for instrument_key in config["observations"]["instruments"]:
out_dir = os.path.join(
work_dir,
"plots",
colormode_key,
"beam_statistics",
ylim_dir,
instrument_key,
)
lfg_dir = os.path.join(
work_dir,
"instruments",
instrument_key,
"light_field_geometry",
)
if not os.path.exists(out_dir):
job = {
"script": "plot_beams_statistics",
"argv": [
"--light_field_geometry_path",
lfg_dir,
"--out_dir",
out_dir,
"--colormode",
colormode_key,
],
}
if ylim:
job["argv"] += ["--ylim_based_on_num_channels"]
jobs.append(job)
return jobs


def _plot_mirror_deformations_make_jobs(work_dir, config=None):
config = utils.config_if_None(work_dir=work_dir, config=config)

Expand Down
9 changes: 7 additions & 2 deletions plenoptics/scripts/plot_beams_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
argparser.add_argument("--light_field_geometry_path", type=str)
argparser.add_argument("--out_dir", type=str)
argparser.add_argument("--colormode", default="default")
argparser.add_argument("--ylim_based_on_num_channels", action="store_true")

args = argparser.parse_args()

colormode = args.colormode
ylim_based_on_num_channels = args.ylim_based_on_num_channels
light_field_geometry_path = args.light_field_geometry_path
out_dir = args.out_dir

Expand All @@ -29,7 +31,6 @@
FIGSTY = {"rows": 960, "cols": 1920, "fontsize": 2.0}
AXSPAN = [0.12, 0.23, 0.87, 0.74]

YLIM = np.array([1, 1e6])
YLABEL = r"intensity$\,/\,$1"


Expand Down Expand Up @@ -183,7 +184,11 @@ def save_histogram(
if np.max(hists[key][met]["v_bin_counts"]) > rrr[met]["max_bin_count"]:
rrr[met]["max_bin_count"] = np.max(hists[key][met]["v_bin_counts"])

rrr[met]["ylim_lin"] = [0, 1.1 * rrr[met]["max_bin_count"]]
if ylim_based_on_num_channels:
rrr[met]["ylim_lin"] = [0, lfg.number_lixel / 7]
else:
rrr[met]["ylim_lin"] = [0, 1.1 * rrr[met]["max_bin_count"]]

rrr[met]["ylim_log"] = [
1,
10 ** np.ceil(np.log10(rrr[met]["max_bin_count"])),
Expand Down
2 changes: 1 addition & 1 deletion plenoptics/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.2.4"
__version__ = "0.2.5"

0 comments on commit 538581b

Please sign in to comment.