diff --git a/HISTORY.rst b/HISTORY.rst index 483ff1bf..39d48a44 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', 'save_figures', '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* 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 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 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): 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/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. diff --git a/frank/fit.py b/frank/fit.py index f580c150..3c62f79e 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 @@ -136,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) @@ -550,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.' @@ -628,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) @@ -641,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'] @@ -657,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'], @@ -672,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) @@ -716,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) @@ -788,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 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. 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'" }, 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 ( diff --git a/frank/statistical_models.py b/frank/statistical_models.py index f7d38014..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: @@ -278,7 +273,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): diff --git a/frank/tests.py b/frank/tests.py index 33d289d8..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'] = True + params['input_output']['save_figures'] = False params['plotting']['distance'] = 121. params['plotting']['bin_widths'] = [1e5] params['plotting']['iter_plot_range'] = [0, 5] 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