Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/lsst-uk/lasair4 into main
Browse files Browse the repository at this point in the history
  • Loading branch information
gpfrancis committed Feb 26, 2024
2 parents 6c2e60d + 56b2021 commit 3b40446
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 75 deletions.
119 changes: 76 additions & 43 deletions webserver/lasair/apps/object/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import math
import numpy as np

filterNames = ['g', 'r']
filterColors = ['#859900', '#dc322f']
filterFids = [1, 2]

def object_difference_lightcurve(
objectData
Expand Down Expand Up @@ -31,10 +34,10 @@ def object_difference_lightcurve(
unforcedDF["marker_opacity"] = 0.6
unforcedDF["name"] = "anon"
symbol_sequence = ["arrow-bar-down-open", "circle"]
unforcedDF.loc[(unforcedDF['fid'] == 1), "marker_color"] = "#859900"
unforcedDF.loc[(unforcedDF['fid'] == 1), "bcolor"] = "#606e03"
unforcedDF.loc[(unforcedDF['fid'] == 2), "marker_color"] = "#dc322f"
unforcedDF.loc[(unforcedDF['fid'] == 2), "bcolor"] = "#b01f1c"
for color,fid in zip(filterColors, filterFids):
unforcedDF.loc[(unforcedDF['fid'] == fid), "marker_color"] = color
unforcedDF.loc[(unforcedDF['fid'] == fid), "bcolor"] = color

unforcedDF.loc[(unforcedDF['candid'] > 0), "marker_symbol"] = "circle-open"
unforcedDF.loc[((unforcedDF['candid'] > 0) & (unforcedDF['isdiffpos'].isin([1, 't']))), "marker_symbol"] = "circle"
unforcedDF.loc[(unforcedDF['candid'] > 0), "marker_size"] = 10
Expand All @@ -43,23 +46,21 @@ def object_difference_lightcurve(
discovery = unforcedDF.loc[(unforcedDF['candid'] > 0)].head(1)

# GENERATE THE DATASETS
gBandData = unforcedDF.loc[(unforcedDF['fid'] == 1)]
rBandData = unforcedDF.loc[(unforcedDF['fid'] == 2)]
rBandDetections = rBandData.loc[(rBandData['candid'] > 0)]
rBandNonDetections = rBandData.loc[~(rBandData['candid'] > 0)]
rBandNonDetections["name"] = "r-band limiting mag"
gBandDetections = gBandData.loc[(gBandData['candid'] > 0)]
gBandNonDetections = gBandData.loc[~(gBandData['candid'] > 0)]
gBandNonDetections["name"] = "g-band limiting mag"
rBandDetectionsPos = rBandDetections.loc[(rBandDetections['isdiffpos'].isin([1, 't']))]
rBandDetectionsNeg = rBandDetections.loc[~(rBandDetections['isdiffpos'].isin([1, 't']))]
gBandDetectionsPos = gBandDetections.loc[(gBandDetections['isdiffpos'].isin([1, 't']))]
gBandDetectionsNeg = gBandDetections.loc[~(gBandDetections['isdiffpos'].isin([1, 't']))]
rBandDetectionsPos["name"] = "r-band detection"
rBandDetectionsNeg["name"] = "r-band neg. flux detection"
gBandDetectionsPos["name"] = "g-band detection"
gBandDetectionsNeg["name"] = "g-band neg. flux detection"
allDataSets = [rBandNonDetections, rBandDetectionsPos, rBandDetectionsNeg, gBandNonDetections, gBandDetectionsPos, gBandDetectionsNeg]
allDataSets = []

for filt,fid in zip(filterNames, filterFids):
BandData = unforcedDF.loc[(unforcedDF['fid'] == fid)]
BandDetections = BandData.loc[(BandData['candid'] > 0)]
BandNonDetections = BandData.loc[~(BandData['candid'] > 0)]
BandNonDetections["name"] = filt + "-band limiting mag"
BandDetectionsPos = BandDetections.loc[(BandDetections['isdiffpos'].isin([1, 't']))]
BandDetectionsNeg = BandDetections.loc[~(BandDetections['isdiffpos'].isin([1, 't']))]
BandDetectionsPos["name"] = filt + "-band detection"
BandDetectionsNeg["name"] = filt + "-band neg. flux detection"

allDataSets.append(BandNonDetections)
allDataSets.append(BandDetectionsPos)
allDataSets.append(BandDetectionsNeg)

# START TO PLOT
from plotly.subplots import make_subplots
Expand Down Expand Up @@ -110,9 +111,18 @@ def object_difference_lightcurve(
# DETERMINE SENSIBLE X-AXIS LIMITS
mjdMin, mjdMax, utcMin, utcMax, fluxMin, fluxMax, magMin, magMax = get_default_axis_ranges(forcedDF, unforcedDF)

fig.update_xaxes(range=[mjdMin, mjdMax], tickformat='d', tickangle=-55, tickfont_size=14, showline=True, linewidth=1.5, linecolor='#1F2937',
if forcedDF is None:
title = "MJD"
tickfont_size = 14
title_font_size = 1
else:
title = ""
tickfont_size = 11
title_font_size = 16

fig.update_xaxes(range=[mjdMin, mjdMax], tickformat='d', tickangle=-55, tickfont_size=tickfont_size, showline=True, linewidth=1.5, linecolor='#1F2937',
gridcolor='#F0F0F0', gridwidth=1,
zeroline=True, zerolinewidth=1.5, zerolinecolor='#1F2937', ticks='inside', title="MJD", title_font_size=16)
zeroline=True, zerolinewidth=1.5, zerolinecolor='#1F2937', ticks='inside', title=title, title_font_size=title_font_size)
fig.update_layout(xaxis2={'range': [utcMin, utcMax],
'showgrid': False,
'anchor': 'y',
Expand Down Expand Up @@ -149,15 +159,19 @@ def object_difference_lightcurve(
fig.update_layout(
plot_bgcolor='white',
paper_bgcolor='white',
height=650,
height=450,
margin_t=0,
margin_b=0,
margin_r=1,
legend=dict(
orientation="h",
orientation="v",
yanchor="top",
y=-0.2,
y=1.0,
xanchor="left",
x=0
x=0,
bgcolor="#E6E5E5",
borderwidth=4,
bordercolor="#E6E5E5",
),
hoverlabel=dict(
font_color="white",
Expand All @@ -179,6 +193,14 @@ def object_difference_lightcurve(
textposition="middle right"
))

fig.update_layout(
title=dict(text="Standard Photometry Magnitudes", font=dict(size=20), y=0.8,
x=0.5,
xanchor='center',
yanchor='top',
font_color="#657b83",)
)

htmlLightcurve = fig.to_html(
config={
'displayModeBar': False,
Expand Down Expand Up @@ -220,21 +242,21 @@ def object_difference_lightcurve_forcedphot(
forcedDF["marker_opacity"] = 0.6
forcedDF["name"] = "anon"
symbol_sequence = ["arrow-bar-down-open", "circle"]
forcedDF.loc[(forcedDF['fid'] == 1), "marker_color"] = "#859900"
forcedDF.loc[(forcedDF['fid'] == 1), "bcolor"] = "#606e03"
forcedDF.loc[(forcedDF['fid'] == 2), "marker_color"] = "#dc322f"
forcedDF.loc[(forcedDF['fid'] == 2), "bcolor"] = "#b01f1c"
for color,fid in zip(filterColors, filterFids):
forcedDF.loc[(forcedDF['fid'] == fid), "marker_color"] = color
forcedDF.loc[(forcedDF['fid'] == fid), "bcolor"] = color

forcedDF["marker_symbol"] = "circle"
forcedDF["marker_size"] = 10

discovery = unforcedDF.loc[(unforcedDF['candid'] > 0)].head(1)

# GENERATE THE DATASETS
gBandDetections = forcedDF.loc[(forcedDF['fid'] == 1)]
rBandDetections = forcedDF.loc[(forcedDF['fid'] == 2)]
gBandDetections["name"] = "g-band detection"
rBandDetections["name"] = "r-band detection"
allDataSets = [gBandDetections, rBandDetections]
allDataSets = []
for filt,fid in zip(filterNames, filterFids):
BandDetections = forcedDF.loc[(forcedDF['fid'] == fid)]
BandDetections["name"] = filt + "-band detection"
allDataSets.append(BandDetections)

# START TO PLOT
from plotly.subplots import make_subplots
Expand All @@ -255,7 +277,7 @@ def object_difference_lightcurve_forcedphot(
error_y_thickness=0.7,
error_y_color=data["bcolor"].values[0],
mode='markers',
showlegend=False,
showlegend=True,
marker_size=data["marker_size"].values[0],
marker_color=data["marker_color"].values[0],
marker_symbol=data["marker_symbol"].values[0],
Expand Down Expand Up @@ -285,14 +307,14 @@ def object_difference_lightcurve_forcedphot(

fig.update_xaxes(range=[mjdMin, mjdMax], tickformat='d', tickangle=-55, tickfont_size=14, showline=True, linewidth=1.5, linecolor='#1F2937',
gridcolor='#F0F0F0', gridwidth=1,
zeroline=True, zerolinewidth=1.5, zerolinecolor='#1F2937', ticks='inside', title_font_size=16)
zeroline=True, zerolinewidth=1.5, zerolinecolor='#1F2937', ticks='inside', title="MJD", title_font_size=16)
fig.update_layout(xaxis2={'range': [utcMin, utcMax],
'showgrid': False,
'anchor': 'y',
'overlaying': 'x',
'side': 'top',
'tickangle': -55,
'tickfont_size': 14,
'tickfont_size': 11,
'showline': True,
'linewidth': 1.5,
'linecolor': '#1F2937'})
Expand Down Expand Up @@ -321,16 +343,19 @@ def object_difference_lightcurve_forcedphot(
fig.update_layout(
plot_bgcolor='white',
paper_bgcolor='white',
height=650,
height=450,
margin_t=0,
margin_b=0,
margin_r=1,
legend=dict(
orientation="h",
orientation="v",
yanchor="top",
y=-0.3,
y=1.0,
xanchor="left",
x=0
x=0,
bgcolor="#E6E5E5",
borderwidth=4,
bordercolor="#E6E5E5",
),
hoverlabel=dict(
font_color="white",
Expand All @@ -352,6 +377,14 @@ def object_difference_lightcurve_forcedphot(
textposition="middle right"
))

fig.update_layout(
title=dict(text="Forced Photometry Flux", font=dict(size=20), y=0.85,
x=0.5,
xanchor='center',
yanchor='top',
font_color="#657b83",)
)

htmlLightcurve = fig.to_html(
config={
'displayModeBar': False,
Expand Down
2 changes: 1 addition & 1 deletion webserver/lasair/templates/includes/navigation.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<path fill-rule="evenodd" d="M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z" clip-rule="evenodd"></path>
</svg>
</span>
<input type="text" list="datalistOptions" class="form-control" id="topbarInputIconLeft" placeholder="Search" aria-label="Search" aria-describedby="topbar-addon" name="query" value="{{query}}">
<input type="text" list="datalistOptions" class="form-control" id="topbarInputIconLeft" placeholder="Object Search" aria-label="Search" aria-describedby="topbar-addon" name="query" value="{{query}}">
<datalist id="datalistOptions">
<option value="ZTF22aafxzfb">Object Name</option>
<option value="SN2022ffg">TNS Id</option>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,45 +36,27 @@ <h2 class="h5 text-gray-400 mb-0 ps-2">Difference Image Lightcurves{% include "i
</small>
</div>
</div>
{% if fplightcurveHtml %}
<div class="card-body pb-0 pt-0">

<div class="d-flex justify-content-center ms-2">
<h4 class="h5 text-gray-400 mb-2 ps-2">Forced{% include "includes/info_tooltip.html" with info="Source photometry calculated by 'forcing' a PSF measurement at the exact location of the object in difference images. Presented in flux-space." position="auto" link=docroot|add:"/concepts/lightcurve.html" %} and Unforced{% include "includes/info_tooltip.html" with info="Photometry collected near the location of the object during difference image processing if a source is detected above a 5𝜎 threshold (less accurate than forced photometry). Presented in magnitude-space." position="auto" link=docroot|add:"/concepts/lightcurve.html" %} Photometry</h2>

</div>
<div class="card-body pt-0">

<div class="w-100 ps-1 pe-1 pb-2">{{ lightcurveHtml|safe }}</div>

{% if fplightcurveHtml %}
<div class="w-100 ps-1 pe-1 pb-2">{{ fplightcurveHtml|safe }}</div>

{% endif %}
</div>


</div>
<div class="card-body pt-0">
{% else %}

<div class="card-body pt-0">
<div class="d-flex justify-content-center ms-2">
<h4 class="h5 text-gray-400 mb-2 ps-2">Unforced Photometry{% include "includes/info_tooltip.html" with info="Photometry collected near the location of the object during difference image processing if a source is detected above a 5𝜎 threshold (less accurate than forced photometry)" position="auto" link=docroot|add:"/concepts/lightcurve.html" %}</h2>

</div>


{% endif %}





<div class="card-body pt-0">

<div class="w-100 ps-1 pe-1 pb-2">{{ lightcurveHtml|safe }}</div>
<div class="d-flex justify-content-end ms-2">
<small class="text-gray-500">
Learn how to <a href="https://plotly.com/chart-studio-help/zoom-pan-hover-controls/">interact with these plots.</a>
</small>
<div class="d-flex justify-content-end ms-2">
<small class="text-gray-500">
Learn how to <a href="https://plotly.com/chart-studio-help/zoom-pan-hover-controls/">interact with these plots.</a>
</small>
</div>
</div>
</div>
</div>



Expand Down
11 changes: 9 additions & 2 deletions webserver/users/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@
from django.contrib.auth.forms import UserCreationForm
from .models import Profile
from crispy_forms.helper import FormHelper
from captcha.fields import ReCaptchaField
from captcha.widgets import ReCaptchaV3
try:
from captcha.fields import ReCaptchaField
except ImportError:
from django_recaptcha.fields import ReCaptchaField
try:
from captcha.widgets import ReCaptchaV3
except ImportError:
from django_recaptcha.widgets import ReCaptchaV3

from django.conf import settings
from django.core.exceptions import ValidationError

Expand Down

0 comments on commit 3b40446

Please sign in to comment.