Skip to content

Commit

Permalink
Merge pull request #209 from discsim/v1.2.2
Browse files Browse the repository at this point in the history
v1.2.2
  • Loading branch information
jeffjennings authored Jul 10, 2023
2 parents f55a412 + 976e986 commit f7b3f2d
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 32 deletions.
26 changes: 26 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down
2 changes: 1 addition & 1 deletion frank/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>
#
__version__ = "1.2.1"
__version__ = "1.2.2"

from frank import constants
from frank import geometry
Expand Down
1 change: 0 additions & 1 deletion frank/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions frank/debris_fitters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions frank/default_parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"save_profile_fit" : true,
"save_vis_fit" : true,
"save_uvtables" : true,
"save_figures" : true,
"iteration_diag" : false,
"format" : null
},
Expand Down
3 changes: 0 additions & 3 deletions frank/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
21 changes: 12 additions & 9 deletions frank/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"""

import os
import sys
import time
import json

Expand All @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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.'
Expand Down Expand Up @@ -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)
Expand All @@ -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']
Expand All @@ -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'],
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions frank/hankel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions frank/parameter_descriptions.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
},
Expand Down
2 changes: 1 addition & 1 deletion frank/radial_fitters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
7 changes: 1 addition & 6 deletions frank/statistical_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,13 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>
#


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:
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion frank/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
1 change: 0 additions & 1 deletion frank/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f7b3f2d

Please sign in to comment.