-
Notifications
You must be signed in to change notification settings - Fork 6
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
Photometric Plot Simplification #176
Changes from all commits
a6700d7
9c26d6e
a1e0483
a6a3831
2e29ce2
ab231da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,6 +190,23 @@ <h2 class="display-4">Companion Relationships</h2> | |
</p> | ||
{% endif %} | ||
</div> | ||
|
||
<div class="row table-responsive"> | ||
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. Separate from PR topic, but I was able to confirm this part is working fine. 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. ah apologies, this was for fixing #166 |
||
{% if everything.modeledparameters %} | ||
<h2 class="display-3"><a href="{{ url_for('create_file_for_download', key='ModeledParameters') }}"> | ||
Modeled Parameters</a></h2> | ||
<p class="display-6"> | ||
{{ everything.modeledparameters|safe }} | ||
</p> | ||
{% else %} | ||
<h2 class="display-4">Modeled Parameters</h2> | ||
<p class="display-6"> | ||
No Modeled Parameters for {{ query|safe }} in the SIMPLE Archive. | ||
If some exists and should be ingested, please open an | ||
<a href="https://github.com/SIMPLE-AstroDB/SIMPLE-db/issues/new?assignees=&labels=data+ingestion&projects=&template=missing_data.md&title=Data+ingest+request+from%3A+%3Cpublication%3E" target="_blank">issue</a>. | ||
</p> | ||
{% endif %} | ||
</div> | ||
</div> | ||
<script> | ||
$(document).ready(function() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -520,6 +520,10 @@ def band_validate(checking_band: str): | |
raise KeyError(f'{checking_band_true} not yet a supported filter') | ||
return checking_band_true | ||
|
||
wanted_mags = {'GAIA3.G', 'GAIA3.Grp', '2MASS.J', '2MASS.H', '2MASS.Ks', 'WISE.W1', 'WISE.W2'} | ||
wanted_cols = {'GAIA3.G-GAIA3.Grp', 'GAIA3.G-2MASS.J', '2MASS.J-2MASS.Ks', '2MASS.H-2MASS.Ks', 'WISE.W1-WISE.W2'} | ||
all_bands = np.array(list(wanted_mags.intersection(all_bands))) | ||
|
||
# looking at each band given in turn | ||
d_cols: Dict[str, np.ndarray] = {} | ||
for band in all_bands: | ||
|
@@ -533,6 +537,9 @@ def band_validate(checking_band: str): | |
# don't make a colour of same band | ||
if band == next_band: | ||
continue | ||
# only want certain colours defined above | ||
elif f'{band}-{next_band}' not in wanted_cols: | ||
continue | ||
|
||
# validate band | ||
next_band_true = band_validate(next_band) | ||
|
@@ -625,33 +632,29 @@ def parse_photometry(photometry_df: pd.DataFrame, all_bands: np.ndarray, multi_s | |
else: | ||
# initialise a DataFrame grouped by each target | ||
df_group_photometry = photometry_df.groupby('source') | ||
d_new_photometry = {col: np.empty(len(df_group_photometry)) for col in all_bands} | ||
d_new_photometry['target'] = np.empty(len(df_group_photometry), dtype=str) | ||
df_new_photometry = pd.DataFrame(d_new_photometry) | ||
|
||
# process the photometry of each source | ||
p = mp.Pool(processes=mp.cpu_count() - 1 or 1) | ||
sources = p.map(one_source_iter, [targetdf for (_, targetdf) in df_group_photometry]) | ||
sources_list: List[Dict[str, object]] = [] # initialize empty list of sources | ||
|
||
# rearrange columns | ||
for i, (target, targetdf) in tqdm(enumerate(df_group_photometry), total=len(df_group_photometry), | ||
desc='Photometry'): | ||
# process photometry of each source | ||
with mp.Pool(processes=mp.cpu_count() - 1 or 1) as pool: | ||
results = pool.map(one_source_iter, [df for _, df in df_group_photometry]) | ||
|
||
specificphoto = sources[i] | ||
for key in df_new_photometry.columns: # over all keys | ||
for (target, _), data in tqdm(zip(df_group_photometry, results), total=len(df_group_photometry), | ||
desc='Photometry'): | ||
|
||
if key == 'target': | ||
df_new_photometry.loc[i, key] = target | ||
row_data = {'target': target} | ||
|
||
# for the magnitude columns | ||
else: | ||
for band in all_bands: | ||
|
||
try: | ||
df_new_photometry.loc[i, key] = specificphoto.loc['magnitude', key] | ||
try: | ||
row_data[band] = data.loc['magnitude', band] | ||
except KeyError: | ||
row_data[band] = None | ||
|
||
sources_list.append(row_data) | ||
|
||
df_new_photometry = pd.DataFrame(sources_list) | ||
|
||
# use None as filler value | ||
except KeyError: | ||
df_new_photometry.loc[i, key] = None | ||
return df_new_photometry | ||
|
||
|
||
|
@@ -758,6 +761,9 @@ def pogson_law(m: Union[float, pd.Series]) -> Union[float, np.ndarray]: | |
_abs_mag[mask] = m[mask] + 5 * np.log10(df.parallax[mask]) - 10 | ||
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. Is there a reason why 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. no real reason other than it's the only place it was needed, and I find it fun taking advantage of encapsulation. I do this in a few places IIRC |
||
return _abs_mag | ||
|
||
wanted_mags = {'GAIA3.G', '2MASS.J', 'WISE.W1'} | ||
all_bands = np.array(list(wanted_mags.intersection(all_bands))) | ||
|
||
# create absolute magnitude for each apparent magnitude | ||
d_magnitudes: Dict[str, np.ndarray] = {} | ||
for band in all_bands: | ||
|
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.
Not sure if you have a test for plot-related functions, but this one would be easy to write tests for.
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.
will add this to #145