-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes to ComparisonViewer for release version of ImageWidget #108
Changes from 5 commits
3fe41f4
4f76131
036b4bd
ddba6d1
df490b5
a2971aa
4418902
826cecd
d2795c3
31d2943
3932ae8
44a4ed4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed redundant import, fixed |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ | |
|
||
from astropy.table import Table | ||
from astropy.coordinates import SkyCoord | ||
from astropy import units as u | ||
from astropy.nddata import CCDData | ||
from astropy import units as u | ||
from astropy.coordinates.name_resolve import NameResolveError | ||
|
@@ -188,12 +187,12 @@ def mag_scale(cmag, apass, v_angle, RD_angle, | |
""" | ||
high_mag = apass['r_mag'] < cmag + dimmer_dmag | ||
low_mag = apass['r_mag'] > cmag - brighter_dmag | ||
if v_angle: | ||
if len(v_angle)>0: | ||
JuanCab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
good_v_angle = v_angle > 1.0 * u.arcsec | ||
else: | ||
good_v_angle = True | ||
|
||
if RD_angle: | ||
if len(RD_angle)>0: | ||
JuanCab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
good_RD_angle = RD_angle > 1.0 * u.arcsec | ||
else: | ||
good_RD_angle = True | ||
|
@@ -392,6 +391,9 @@ class ComparisonViewer: | |
aperture_output_file : str, optional | ||
File to save aperture information to. Defaults to None. | ||
|
||
overwrite_outputs: bool, optional | ||
Whether to overwrite existing output files. Defaults to True. | ||
|
||
Attributes | ||
---------- | ||
|
||
|
@@ -410,6 +412,9 @@ class ComparisonViewer: | |
iw : `ginga.util.grc.RemoteClient` | ||
Ginga widget. | ||
|
||
overwrite_outputs: bool | ||
Whether to overwrite existing output files. Defaults to True. | ||
|
||
target_coord : `astropy.coordinates.SkyCoord` | ||
Coordinates of the target. | ||
|
||
|
@@ -432,7 +437,8 @@ def __init__(self, | |
dim_mag_limit=17, | ||
targets_from_file=None, | ||
object_coordinate=None, | ||
aperture_output_file=None): | ||
aperture_output_file=None, | ||
overwrite_outputs=True): | ||
|
||
self._label_name = 'labels' | ||
self._circle_name = 'target circle' | ||
|
@@ -450,6 +456,7 @@ def __init__(self, | |
self.box, self.iw = self._viewer() | ||
|
||
self.aperture_output_file = aperture_output_file | ||
self.overwrite_outputs = overwrite_outputs | ||
|
||
if file: | ||
self._file_chooser.set_file(file, directory=directory) | ||
|
@@ -564,7 +571,8 @@ def _make_observers(self): | |
def _save_variables_to_file(self, button=None, filename=''): | ||
if not filename: | ||
filename = 'variables.csv' | ||
self.variables.write(filename) | ||
# Export variables as CSV (overwrite existing file if it exists) | ||
self.variables.write(filename, overwrite=self.overwrite_outputs) | ||
|
||
def _show_label_button_handler(self, change): | ||
value = change['new'] | ||
|
@@ -580,8 +588,8 @@ def _show_label_button_handler(self, change): | |
def _save_aperture_to_file(self, button=None, filename=''): | ||
if not filename: | ||
filename = self.aperture_output_file | ||
|
||
self.generate_table().write(filename) | ||
# Export aperture file as CSV (overwrite existing file if it exists) | ||
self.generate_table().write(filename, overwrite=self.overwrite_outputs) | ||
|
||
def _make_control_bar(self): | ||
self._show_labels_button = ipw.ToggleButton(description='Click to show labels') | ||
|
@@ -707,11 +715,23 @@ def save_tess_files(self, button=None): | |
""" | ||
if self._field_name.value: | ||
self.tess_field_view() | ||
self.iw.save(self._field_name.value, overwrite=True) | ||
# Remove output file if it exists | ||
if Path(self._field_name.value).exists() and self.overwrite_outputs: | ||
Path(self._field_name.value).unlink() | ||
try: | ||
self.iw.save(self._field_name.value) | ||
except: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Usually it is better to not use a bare There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh crap, I forgot to capture the specific error. I ended up wrapping all the file creation calls that could fail due to attempting to overwrite a file without permission with a try..except OSError. That should be specific enough. I notice the errors still show up on the Jupyterlab log page, so may not really be much easier for users. |
||
print("Error saving full field image.") | ||
|
||
if self._zoom_name.value: | ||
self.tess_field_zoom_view() | ||
self.iw.save(self._zoom_name.value, overwrite=True) | ||
# Remove output file if it exists | ||
if Path(self._zoom_name.value).exists() and self.overwrite_outputs: | ||
Path(self._zoom_name.value).unlink() | ||
try: | ||
self.iw.save(self._zoom_name.value) | ||
except: | ||
print("Error saving zoomed in full field image.") | ||
|
||
def generate_table(self): | ||
""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make the GAIA aperture server hardcoded. Seemed to make sense.