From 6de92b4fc020697f4172a65dbf008608020ec405 Mon Sep 17 00:00:00 2001 From: Jeff Jennings Date: Thu, 6 Jul 2023 08:34:25 -0400 Subject: [PATCH 01/16] resolve DeprecationWarning --- frank/statistical_models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frank/statistical_models.py b/frank/statistical_models.py index f7d38014..d5d2802b 100644 --- a/frank/statistical_models.py +++ b/frank/statistical_models.py @@ -278,7 +278,7 @@ def check_hash(self, hash, multi_freq=False, geometry=None): if hash[4] is None: return False else: - return np.alltrue(self._scale_height == hash[4]) + return np.all(self._scale_height == hash[4]) def predict_visibilities(self, I, q, k=None, geometry=None): From 7c72098ddcace981dc313443f67e101ed034d020 Mon Sep 17 00:00:00 2001 From: Jeff Jennings Date: Thu, 6 Jul 2023 08:34:40 -0400 Subject: [PATCH 02/16] constants: unused imports --- frank/constants.py | 1 - 1 file changed, 1 deletion(-) diff --git a/frank/constants.py b/frank/constants.py index fca589c3..b083c238 100644 --- a/frank/constants.py +++ b/frank/constants.py @@ -19,7 +19,6 @@ """This module contains useful conversion constants.""" import numpy as np -from scipy.constants import c rad_to_arcsec = 3600 * 180 / np.pi sterad_to_arcsec = rad_to_arcsec ** 2 From e2c4ddf5acf193e183ad7fbd971d534f65d16d7b Mon Sep 17 00:00:00 2001 From: Jeff Jennings Date: Thu, 6 Jul 2023 08:34:50 -0400 Subject: [PATCH 03/16] debris_fitters: unused imports --- frank/debris_fitters.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/frank/debris_fitters.py b/frank/debris_fitters.py index 0b20f0a3..8715a4ee 100644 --- a/frank/debris_fitters.py +++ b/frank/debris_fitters.py @@ -21,11 +21,6 @@ of deprojected visibities. Routines in this file assume that the emission is optically thin with a Gaussian vertical structure. """ -import abc -from collections import defaultdict -import logging -import numpy as np - from frank.radial_fitters import FourierBesselFitter, FrankFitter class FourierBesselDebrisFitter(FourierBesselFitter): From 168b470db75cfa4c63253230198f491606fc0eec Mon Sep 17 00:00:00 2001 From: Jeff Jennings Date: Thu, 6 Jul 2023 08:35:00 -0400 Subject: [PATCH 04/16] filter: unused imports --- frank/filter.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/frank/filter.py b/frank/filter.py index 9dc0c2fc..a5719531 100644 --- a/frank/filter.py +++ b/frank/filter.py @@ -20,9 +20,6 @@ import numpy as np import scipy.sparse -from frank.constants import rad_to_arcsec - - def spectral_smoothing_matrix(DHT, weights): r"""Compute the spectral smoothing prior matrix, Tij. From f2d0b99a43862244836a0d5698f2077683280f55 Mon Sep 17 00:00:00 2001 From: Jeff Jennings Date: Thu, 6 Jul 2023 08:35:13 -0400 Subject: [PATCH 05/16] fit: unused imports --- frank/fit.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/frank/fit.py b/frank/fit.py index f580c150..b92ddd78 100644 --- a/frank/fit.py +++ b/frank/fit.py @@ -22,7 +22,6 @@ """ import os -import sys import time import json @@ -38,7 +37,6 @@ def _check_and_warn_if_parallel(): "'export OMP_NUM_THREADS=1' to disable this warning.") import numpy as np - import logging import frank From 1cd24621c7781c60ccf5fd21cc5083226b74956f Mon Sep 17 00:00:00 2001 From: Jeff Jennings Date: Thu, 6 Jul 2023 08:35:28 -0400 Subject: [PATCH 06/16] hankel: unused imports --- frank/hankel.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/frank/hankel.py b/frank/hankel.py index 23de5d54..8503d890 100644 --- a/frank/hankel.py +++ b/frank/hankel.py @@ -19,13 +19,9 @@ """This module contains functions for computing the discrete Hankel transform (DHT). """ - import numpy as np from scipy.special import j0, j1, jn_zeros, jv -from frank.constants import rad_to_arcsec - - class DiscreteHankelTransform(object): r""" Utilities for computing the discrete Hankel transform. From a70524a8fb6c2574cf990c3dc58f40d1edaffe18 Mon Sep 17 00:00:00 2001 From: Jeff Jennings Date: Thu, 6 Jul 2023 08:36:00 -0400 Subject: [PATCH 07/16] radial_fitters: unused imports --- frank/radial_fitters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frank/radial_fitters.py b/frank/radial_fitters.py index 7706d355..81a0e65c 100644 --- a/frank/radial_fitters.py +++ b/frank/radial_fitters.py @@ -25,7 +25,7 @@ import logging import numpy as np -from frank.constants import deg_to_rad, rad_to_arcsec +from frank.constants import rad_to_arcsec from frank.filter import CriticalFilter from frank.hankel import DiscreteHankelTransform from frank.statistical_models import ( From 061ad006bcf0a92c66715ba4e4156097fb7257e0 Mon Sep 17 00:00:00 2001 From: Jeff Jennings Date: Thu, 6 Jul 2023 08:36:16 -0400 Subject: [PATCH 08/16] statistical_models: unused imports --- frank/statistical_models.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/frank/statistical_models.py b/frank/statistical_models.py index d5d2802b..46db07b7 100644 --- a/frank/statistical_models.py +++ b/frank/statistical_models.py @@ -17,18 +17,13 @@ # along with this program. If not, see # - -import multiprocessing import numpy as np import scipy.linalg import scipy.sparse import scipy.optimize -from collections import defaultdict import logging -from frank.hankel import DiscreteHankelTransform from frank.constants import rad_to_arcsec, deg_to_rad - from frank.minimizer import LineSearch, MinimizeNewton class VisibilityMapping: From 1bd4754ee9204eb59bf41c0aaaae575a30e2851b Mon Sep 17 00:00:00 2001 From: Jeff Jennings Date: Thu, 6 Jul 2023 08:36:27 -0400 Subject: [PATCH 09/16] utilities: unused imports --- frank/utilities.py | 1 - 1 file changed, 1 deletion(-) diff --git a/frank/utilities.py b/frank/utilities.py index debc0816..660223aa 100644 --- a/frank/utilities.py +++ b/frank/utilities.py @@ -21,7 +21,6 @@ """ import logging import numpy as np -from scipy.fft import fftfreq from scipy.interpolate import interp1d from frank.constants import deg_to_rad, sterad_to_arcsec, rad_to_arcsec From 26a285ca13284db5e9901f4e0595855c34bef85a Mon Sep 17 00:00:00 2001 From: Jeff Jennings Date: Thu, 6 Jul 2023 08:36:54 -0400 Subject: [PATCH 10/16] update changelog in HISTORY for v1.2.2 --- HISTORY.rst | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index 483ff1bf..95575298 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -3,6 +3,32 @@ Changelog +++++++++ +v.1.2.2 ++++++++ +*One bug fix, some code refactoring, a couple new functionalities, integrates scale-height fits into command-line UI* + +- default_parameters.json, parameter_descriptions.json: + - Adds parameters: 'convergence_failure', 'I_scale', 'scale_height' +- filter.py + - Breaks 'spectral_smoothing_matrix' out of 'CriticalFilter'; some restructuring of 'covariance_MAP' and 'log_prior' +- fit.py + - Adds 'get_scale_height' function +- hankel.py + - Adds 'interpolation_coefficients' and 'interpolate' functions +- io.py + - Fixed a bug that was saving incorrect uncertainty for LogNormal brightness profile +- make_figs.py + - Adds non-negative fit to figures +- radial_fitters.py + - Adds 'convergence_failure' arg to FrankFitter + - Adds 'log_evidence_laplace' function to FrankFitter +- statistical_models.py + - Adds 'DHT_coefficients' and 'interpolate' functions to 'VisibilityMapping' +- test.py + - Adds tests for non-negative solver ('test_solve_non_negative') and solution object IO ('test_save_load_sol') +- utilities.py + - Adds 'get_fit_stat_uncer' function + v.1.2.1 +++++++ *Fixed a bug that caused non-python files to not be installed through pip* From cb7f7155bbefa1d453bf4b3bf0b30079f67a02a2 Mon Sep 17 00:00:00 2001 From: Jeff Jennings Date: Thu, 6 Jul 2023 08:37:08 -0400 Subject: [PATCH 11/16] bump version in __init__ --- frank/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frank/__init__.py b/frank/__init__.py index c1bd9151..0c684ae9 100644 --- a/frank/__init__.py +++ b/frank/__init__.py @@ -16,7 +16,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see # -__version__ = "1.2.1" +__version__ = "1.2.2" from frank import constants from frank import geometry From 2c4ea697526c3e570d7f415b36dfa54583eb8513 Mon Sep 17 00:00:00 2001 From: Jeff Jennings Date: Thu, 6 Jul 2023 08:57:58 -0400 Subject: [PATCH 12/16] tests: don't save figs --- frank/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frank/tests.py b/frank/tests.py index 33d289d8..42e0babc 100644 --- a/frank/tests.py +++ b/frank/tests.py @@ -528,7 +528,7 @@ def _run_pipeline(geometry='gaussian', fit_phase_offset=True, params['plotting']['full_plot'] = True params['plotting']['diag_plot'] = True params['plotting']['deprojec_plot'] = True - params['plotting']['save_figs'] = True + params['plotting']['save_figs'] = False params['plotting']['distance'] = 121. params['plotting']['bin_widths'] = [1e5] params['plotting']['iter_plot_range'] = [0, 5] From 80da575caba7ddd31d821d5c33ac0ff97cfa2307 Mon Sep 17 00:00:00 2001 From: Jeff Jennings Date: Thu, 6 Jul 2023 09:14:13 -0400 Subject: [PATCH 13/16] add 'save_figures' json arg --- frank/default_parameters.json | 1 + frank/parameter_descriptions.json | 1 + 2 files changed, 2 insertions(+) diff --git a/frank/default_parameters.json b/frank/default_parameters.json index 7b997bbd..8d737498 100644 --- a/frank/default_parameters.json +++ b/frank/default_parameters.json @@ -6,6 +6,7 @@ "save_profile_fit" : true, "save_vis_fit" : true, "save_uvtables" : true, + "save_figures" : true, "iteration_diag" : false, "format" : null }, diff --git a/frank/parameter_descriptions.json b/frank/parameter_descriptions.json index 63bfa3e3..1a39c177 100644 --- a/frank/parameter_descriptions.json +++ b/frank/parameter_descriptions.json @@ -6,6 +6,7 @@ "save_profile_fit" : "Whether to save fitted brightness profile", "save_vis_fit" : "Whether to save fitted visibility distribution", "save_uvtables" : "Whether to save fitted and residual UV tables (these are reprojected)", + "save_figures" : "Whether to save generated figures selected in 'plotting'", "iteration_diag" : "Whether to return and save diagnostics of the fit iteration (needed for diag_plot)", "format" : "Output file format. Default is the same as for 'uvtable_filename', else choose from 'npz' or 'txt'" }, From 608da03dff79ef26757158985530564466412d00 Mon Sep 17 00:00:00 2001 From: Jeff Jennings Date: Thu, 6 Jul 2023 09:15:00 -0400 Subject: [PATCH 14/16] add 'fig_save_prefix' arg to optionally save figs --- frank/fit.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/frank/fit.py b/frank/fit.py index b92ddd78..3c62f79e 100644 --- a/frank/fit.py +++ b/frank/fit.py @@ -134,6 +134,11 @@ def parse_parameters(*args): os.path.join(model['input_output']['save_dir'], os.path.splitext(os.path.basename(uv_path))[0]) + if model['input_output']['save_figures'] is True: + model['input_output']['fig_save_prefix'] = save_prefix + else: + model['input_output']['fig_save_prefix'] = None + log_path = save_prefix + '_frank_fit.log' frank.enable_logging(log_path) @@ -548,7 +553,7 @@ def number_to_list(x): bin_widths=model['plotting']['bin_widths'], dist=model['plotting']['distance'], force_style=model['plotting']['force_style'], - save_prefix=model['input_output']['save_prefix'], + save_prefix=model['input_output']['fig_save_prefix'], ) else: logging.info('The multifit figure requires alpha and wsmooth to be lists of length <= 2.' @@ -626,7 +631,7 @@ def output_results(u, v, vis, weights, sol, geom, model, iteration_diagnostics=N geom=geom, bin_widths=model['plotting']['bin_widths'], force_style=model['plotting']['force_style'], - save_prefix=model['input_output']['save_prefix'] + save_prefix=model['input_output']['fig_save_prefix'] ) figs.append(deproj_fig) @@ -639,7 +644,7 @@ def output_results(u, v, vis, weights, sol, geom, model, iteration_diagnostics=N dist=model['plotting']['distance'], logx=model['plotting']['plot_in_logx'], force_style=model['plotting']['force_style'], - save_prefix=model['input_output']['save_prefix'], + save_prefix=model['input_output']['fig_save_prefix'], stretch=model['plotting']['stretch'], gamma=model['plotting']['gamma'], asinh_a=model['plotting']['asinh_a'] @@ -655,7 +660,7 @@ def output_results(u, v, vis, weights, sol, geom, model, iteration_diagnostics=N dist=model['plotting']['distance'], logx=model['plotting']['plot_in_logx'], force_style=model['plotting']['force_style'], - save_prefix=model['input_output']['save_prefix'], + save_prefix=model['input_output']['fig_save_prefix'], norm_residuals=model['plotting']['norm_residuals'], stretch=model['plotting']['stretch'], gamma=model['plotting']['gamma'], @@ -670,7 +675,7 @@ def output_results(u, v, vis, weights, sol, geom, model, iteration_diagnostics=N iteration_diagnostics=iteration_diagnostics, iter_plot_range=model['plotting']['iter_plot_range'], force_style=model['plotting']['force_style'], - save_prefix=model['input_output']['save_prefix'] + save_prefix=model['input_output']['fig_save_prefix'] ) figs.append(diag_fig) @@ -714,7 +719,7 @@ def output_results(u, v, vis, weights, sol, geom, model, iteration_diagnostics=N MAP_convolved=MAP_convolved, dist=model['plotting']['distance'], force_style=model['plotting']['force_style'], - save_prefix=model['input_output']['save_prefix'] + save_prefix=model['input_output']['fig_save_prefix'] ) figs.append(clean_fig) @@ -786,7 +791,7 @@ def perform_bootstrap(u, v, vis, weights, geom, model): boot_fig, boot_axes = make_figs.make_bootstrap_fig(r=sol.r, profiles=profiles_bootstrap, force_style=model['plotting']['force_style'], - save_prefix=model['input_output']['save_prefix'] + save_prefix=model['input_output']['fig_save_prefix'] ) return boot_fig, boot_axes From a783dd22dd7da5d2815f8bb84fc27cce85ebac4b Mon Sep 17 00:00:00 2001 From: Jeff Jennings Date: Thu, 6 Jul 2023 09:15:17 -0400 Subject: [PATCH 15/16] update old arg name in tests --- frank/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frank/tests.py b/frank/tests.py index 42e0babc..b195432b 100644 --- a/frank/tests.py +++ b/frank/tests.py @@ -528,7 +528,7 @@ def _run_pipeline(geometry='gaussian', fit_phase_offset=True, params['plotting']['full_plot'] = True params['plotting']['diag_plot'] = True params['plotting']['deprojec_plot'] = True - params['plotting']['save_figs'] = False + params['input_output']['save_figures'] = False params['plotting']['distance'] = 121. params['plotting']['bin_widths'] = [1e5] params['plotting']['iter_plot_range'] = [0, 5] From 976e98673b00fe4a42cca6c19011b036e09d2148 Mon Sep 17 00:00:00 2001 From: Jeff Jennings Date: Thu, 6 Jul 2023 09:15:40 -0400 Subject: [PATCH 16/16] note new arg addition in changelong --- HISTORY.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index 95575298..39d48a44 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -8,7 +8,7 @@ v.1.2.2 *One bug fix, some code refactoring, a couple new functionalities, integrates scale-height fits into command-line UI* - default_parameters.json, parameter_descriptions.json: - - Adds parameters: 'convergence_failure', 'I_scale', 'scale_height' + - Adds parameters: 'convergence_failure', 'I_scale', 'save_figures', 'scale_height' - filter.py - Breaks 'spectral_smoothing_matrix' out of 'CriticalFilter'; some restructuring of 'covariance_MAP' and 'log_prior' - fit.py