Skip to content
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

UI work #278

Merged
merged 19 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
206 changes: 206 additions & 0 deletions autoui_widget_viewer.ipynb
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did note review notebook beyond GitHub changes interface, looks like mostly markdown changes anyway.

Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "9be000e1-91c2-4686-972e-fadbfd26a834",
"metadata": {},
"outputs": [],
"source": [
"from pathlib import Path\n",
"\n",
"from astropy.table import Table"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6ecbdeea-e2f0-46f6-bcc4-33edc5c7e2a4",
"metadata": {},
"outputs": [],
"source": [
"from ipyautoui import AutoUi\n",
"import ipywidgets as ipw"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b291300e-1bb2-4f00-96c7-4236286d0c2e",
"metadata": {},
"outputs": [],
"source": [
"from stellarphot import SourceListData\n",
"\n",
"from stellarphot.settings import (\n",
" Camera, \n",
" LoggingSettings,\n",
" Observatory, \n",
" PhotometryApertures, \n",
" Exoplanet, \n",
" PhotometrySettings, \n",
" PhotometryOptions,\n",
" PassbandMap,\n",
" SourceLocationSettings,\n",
")\n",
"from stellarphot.settings.models import _extract_short_description\n",
"from stellarphot.settings import ui_generator\n",
"from pydantic import BaseModel"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c6dab0a9-e02c-4f06-a1da-4a6349ac1796",
"metadata": {},
"outputs": [],
"source": [
"sl = SourceListData(Table({'star_id': [1, 2], 'ra': [0.1, 0.2], 'dec': [12.3, 12.2]}, units=[None, \"degree\", \"degree\"]))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9234124e-bf47-45cf-ad8b-0531d60bdcda",
"metadata": {},
"outputs": [],
"source": [
"sl.write(\"source_list_file.ecsv\", overwrite=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ac061641-c4bd-4425-adfd-531cc311ce00",
"metadata": {},
"outputs": [],
"source": [
"classes = [Camera, Observatory, PassbandMap, PhotometryApertures, SourceLocationSettings, PhotometryOptions, LoggingSettings]\n",
"\n",
"uis = [ui_generator(c) for c in classes]\n",
"\n",
"for ui in uis:\n",
" ui.path = Path(ui.title + \".json\")"
]
},
{
"cell_type": "markdown",
"id": "93beccb6-9ec0-4a78-bf24-68bfa18f0e03",
"metadata": {},
"source": [
"# Instructions\n",
"\n",
"1. Guidance about entering some of the values that are needed is in the section \"Entering values\"\n",
"2. After that, there are two sections wehere you will try entring some settings. Please try each and take notes on what like/don't like/are confused about.\n",
"3. In each, click the green save button to make a json file with those settings.\n",
"4. When you are done, please email your comments and any json files made by this notebook."
]
},
{
"cell_type": "markdown",
"id": "f24eb5a3-308b-43c6-920e-cfccb1623ac1",
"metadata": {},
"source": [
"## Entering values\n",
"\n",
"+ **Values with units**\n",
" + Some values, like gain for the camera, needs units. Enter those by typing the number and units into the box, e.g. \"1.5 electron / adu\".\n",
" + In the observatory section, enter latitude and longitude as decimal degrees, and include a unit, e.g. meter, in the elevation.\n",
"+ **Passband map**: There are three buttons to push to get to the point where you can enter a filter and choose the AAVSO filter it matches to. See the screenshot below. A good test value here is to put in `rp` for \"your\" filter, and choose `SR` as the corresponding AAVSO filter.\n",
"\n",
"![Passband map](https://previews.dropbox.com/p/thumb/ACOJuKO0mOe-FFWBDAjYqDSLAo8q90yIca18V1Ln7ksUyukXvlp0TRcQJEhipsx140ksInFiC0uvABV0eO8pTCqfrQcBbcMXVYiAPYIzf7DVI8HMJdZk2Wc0JmJMxAFgG2Cq-4wc2LegVJabF5MhPwEOAywfnq_IV_U8OgJFLgGb5iFFDLAMSgC8fwiU0jRdPIwB2tQcFGWlV5pJU0qBhfbWyNxwSqylvXThBjcAKDtvdcrVcUOxcaaiY_Qn7e8Ee_3mcD2oWPypz-Ov-V-5gIzPZVFSCaVRWBBblb_zEDQJ1TBCA2LSXikLf5G2vq4f0san4URsqttJJxAKrhSFW9q9/p.png)"
]
},
{
"cell_type": "markdown",
"id": "ca552437-3287-4ca4-8f3a-8cef709c0932",
"metadata": {},
"source": [
"## Individual setting groups\n",
"\n",
"Please try filling out the individual groups of settings below. Note anything you find confusing, unusual, or incorrect.\n",
"\n",
"For each setting group, once the settings are \"Valid\" please press the green \"Save\" icon for that group. That will generate one file per tab, so 7 files total. Please email those along with your experience with the interface."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3d26814b-775e-4f72-b535-ebce1b23e5d6",
"metadata": {},
"outputs": [],
"source": [
"tabs = ipw.Tab()\n",
"tabs.children = uis\n",
"tabs.titles = [c.__name__ for c in classes]\n",
"tabs"
]
},
{
"cell_type": "markdown",
"id": "6124aab2-449a-40b0-8284-f3b96e2d77de",
"metadata": {},
"source": [
"## Combined settings\n",
"\n",
"This is the same set of information you enetered above but now presented as a single interface. Please fill this version out and note anything you find confusing, unusual, or incorrect.\n",
"\n",
"For each group of settings (camera, obervatory, etc) click the \"Show\" button to view that item's settings.\n",
"\n",
"When you have finished the settings please click the green \"Save\" icon and and email the file."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "89472b65-69f5-439f-b34c-e26e3133e84c",
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"all_photom = AutoUi(PhotometrySettings)\n",
"all_photom.path = Path(\"combined_photometry_settings.json\")\n",
"all_photom.show_validation = False\n",
"all_photom"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "51403657-ca4e-4615-bc59-65b93e3fad6d",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "c2cdc0a5-7788-49a8-974e-e2a5891c2c53",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
22 changes: 21 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,27 @@ Getting Started
Installation
------------

Install it with pip or conda.
Testing
+++++++

If you are testing a pre-release version of stellarphot we recommend setting up
a virtual environment and installing stellarphot in this environment.

Creating an environment with `conda` or `mamba`:

```bash
mamba create -n stellarphot-test python=3.11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So does stellarphot-test have all the dependencies defined? I have my own testing environment for stellarphot under conda and I should probably compare the two setups.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No -- this section should be modified/removed. For testing of this branch I sent the instructions below. It creates a bare-bones environment then pip installs everything from a github URL so people can try out the UI independent of whether we've done a pre-release or not and dodging all of the intricacies of git:


This first look will be to try out a couple of jupyter notebook-based forms for entering a bunch of settings.

I’d recommend, for now, that when you are testing you make a python environment for testing in, the delete the environment when you are done instead of trying to frequently update stellarphot. Instructions for doing that if you use conda are below, happy to provide non-conda instructions too.

To make an environment for testing called sp-test:

conda create -n sp-test python=3.11

When the environment is created, activate it:

conda ativaste sp-test

The command to install the version of stellarphot to try this time around is:

pip install git+https://github.com/mwcraig/stellarphot.git@ui-work

When this is done, please save the attached notebook to a folder, and navigate into that folder in the terminal. Run “jupyter lab” to start up jupyter and try going through the notebook. After several cells of set up it will present forms for you to enter settings. Don’t worry about using realistic values for now.

I’m expecting you will have questions and that it needs more instructions, but figured getting a quick look sooner was better than waiting longer.

When you are done you can deactivate the environment and then remove it:

conda deactivate
conda remove --all --yes sp-test

mamba activate stellarphot-test
pip install --pre --upgrade stellarphot
```

Creating an environment with `virtualenv`:

```bash
python3 -m venv stellarphot-test
source stellarphot-test/bin/activate
pip install --pre --upgrade stellarphot
```

Overview
--------
Expand Down
9 changes: 7 additions & 2 deletions stellarphot/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,14 @@ def _update_passbands(self):
# in case any of the new names are longer than the longest of the old names.
# If that happens, astropy by default just truncates the names.
new_filter_name = [
self._passband_map[orig_pb] if orig_pb in self._passband_map else orig_pb
(
self._passband_map[orig_pb]
if orig_pb in self._passband_map.keys()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the default iterator for a dictionary keys? Oh, I see, you defined a method keys for the PassbandModel that returns the keys. Later I do see where you perform self._passband_map = passband_map.model_copy() to set self._passband_map... but passband_map is a dict according to the docstrings forCatalogData and PhotometryData . Does this need to get changed to PassbandMap object?

Did you place this function the BaseEnhancedTable so it is available to be inherited by CatalogData and PhotometryData? I ask because the passband mapping is not used in the BaseEnhancedTable.

Finally, what is self["passband"]? I can't find where self["passband"] is even defined in BaseEnhancedTable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taking a look in a moment -- the intent was to have every place use a PassbandMap object but to make that object act sort of like a dict.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, you are write that the default iterator is over keys, but I wasn't sure which dunder method I needed to use to make that happen. Can dig it up in Fluent Python probably.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you place this function the BaseEnhancedTable so it is available to be inherited by CatalogData and PhotometryData? I ask because the passband mapping is not used in the BaseEnhancedTable.

I think _update_passbands has been in BaseEnhancedTable for a while: https://github.com/feder-observatory/stellarphot/blob/main/stellarphot/core.py#L166

I do think you are correct about the reason it is in BaseEnhancedTable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally, what is self["passband"]?

Took me a sec to remember, it is one of the columns in the table.

else orig_pb
)
for orig_pb in self["passband"]
]
print(new_filter_name)
self["passband"] = new_filter_name

def clean(self, remove_rows_with_mask=False, **other_restrictions):
Expand Down Expand Up @@ -541,7 +546,7 @@ def __init__(

# Apply the filter/passband name update
if passband_map is not None:
self._passband_map = passband_map.copy()
self._passband_map = passband_map.model_copy()
JuanCab marked this conversation as resolved.
Show resolved Hide resolved
self._update_passbands()

def add_bjd_col(self, observatory):
Expand Down
17 changes: 10 additions & 7 deletions stellarphot/photometry/tests/test_photometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
Camera,
LoggingSettings,
Observatory,
PassbandMap,
PhotometryApertures,
PhotometryOptions,
PhotometrySettings,
Expand Down Expand Up @@ -87,10 +88,12 @@
)

# Passband map for the tests
PASSBAND_MAP = {
"B": "B",
"rp": "SR",
}
PASSBAND_MAP = PassbandMap(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is using the pydantic model... but stellarphot/core wasn't?

your_filter_names_to_aavso={
"B": "B",
"rp": "SR",
}
)

DEFAULT_LOGGING_SETTINGS = LoggingSettings()

Expand All @@ -100,7 +103,7 @@
photometry_apertures=DEFAULT_PHOTOMETRY_APERTURES,
source_locations=DEFAULT_SOURCE_LOCATIONS,
photometry_options=PHOTOMETRY_OPTIONS,
passband_map=None,
passband_map=PASSBAND_MAP,
logging_settings=DEFAULT_LOGGING_SETTINGS,
)

Expand Down Expand Up @@ -208,7 +211,7 @@ def test_aperture_photometry_no_outlier_rejection(self, int_data, tmp_path):
photometry_apertures=DEFAULT_PHOTOMETRY_APERTURES,
source_locations=source_locations,
photometry_options=phot_options,
passband_map=None,
passband_map=PASSBAND_MAP,
logging_settings=DEFAULT_LOGGING_SETTINGS,
)

Expand Down Expand Up @@ -809,7 +812,7 @@ def test_aperture_photometry_no_outlier_rejection(int_data, tmp_path):
photometry_apertures=DEFAULT_PHOTOMETRY_APERTURES,
source_locations=source_locations,
photometry_options=phot_options,
passband_map=None,
passband_map=PASSBAND_MAP,
logging_settings=DEFAULT_LOGGING_SETTINGS,
)
phot, missing_sources = single_image_photometry(
Expand Down
38 changes: 38 additions & 0 deletions stellarphot/settings/aavso_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from enum import Enum


class AAVSOFilters(str, Enum):
U = "U"
B = "B"
V = "V"
R = "R"
Rc = "R"
I = "I" # noqa: E741
Ic = "I"
J = "J"
H = "H"
K = "K"
TG = "TG"
TB = "TB"
TR = "TR"
CV = "CV"
CR = "CR"
SZ = "SZ"
SU = "SU"
SG = "SG"
SR = "SR"
SI = "SI"
STU = "STU"
STV = "STV"
STB = "STB"
STY = "STY"
STHBW = "STHBW"
STHBN = "STHBN"
MA = "MA"
MB = "MB"
MI = "MI"
ZS = "ZS"
Y = "Y"
HA = "HA"
HAC = "HAC"
O = "O" # noqa: E741
Loading