Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
36 changes: 17 additions & 19 deletions mop/toolbox/obs_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def build_and_submit_phot(target, obs_type):

#Probably gonna need a MUSCAT exception



mag_now = TAP.TAP_mag_now(target)
mag_exposure = mag_now
Expand All @@ -231,7 +231,7 @@ def build_and_submit_phot(target, obs_type):

start = Time(datetime.datetime.utcnow())
end = Time(datetime.datetime.utcnow()+datetime.timedelta(days=obs_duration))

visible_at_muscat = calculate_visibility(target.ra, target.dec, start, end, 'OGG', max_airmass=max_airmass)
moon_sep_at_muscat = all_night_moon_sep(target.ra, target.dec, start, end, 'OGG', sample_size=75)

Expand Down Expand Up @@ -366,7 +366,6 @@ def build_and_submit_muscat(target, obs_type):
#Defaults
observing_type = 'IMAGING'
instrument_type = '2M0-SCICAM-MUSCAT'
type = 'REPEAT_EXPOSE'
proposal = os.getenv('LCO_PROPOSAL_ID')
facility = 'LCO'
observation_mode = 'NORMAL'
Expand Down Expand Up @@ -419,16 +418,16 @@ def build_and_submit_muscat(target, obs_type):
exposure_time_z = exposure_time_i
exposure_time = max(exposure_time_g, exposure_time_r, exposure_time_i, exposure_time_z)

diffuser_g_position = 'OUT'
diffuser_r_position = 'OUT'
diffuser_i_position = 'OUT'
diffuser_z_position = 'OUT'
diffuser_g_position = 'out'
diffuser_r_position = 'out'
diffuser_i_position = 'out'
diffuser_z_position = 'out'

start = datetime.datetime.utcnow().isoformat()
end = (datetime.datetime.utcnow()+datetime.timedelta(days=obs_duration)).isoformat()

obs_dic = {} # ASYNCHRONOUS MODE

obs_dic['name'] = obs_name
obs_dic['target_id'] = target.id
obs_dic['start'] = start
Expand All @@ -437,19 +436,18 @@ def build_and_submit_muscat(target, obs_type):

obs_dic['ipp_value'] = ipp
obs_dic['exposure_count'] = 1
# obs_dic['repeat_duration'​] = 14400 # 4 hours. Not sure how to make sure this happens each night
obs_dic['exposure_mode'] = 'ASYNCHRONOUS'
obs_dic['exposure_time_g'] = exposure_time_g
obs_dic['exposure_time_r'] = exposure_time_r
obs_dic['exposure_time_i'] = exposure_time_i
obs_dic['exposure_time_z'] = exposure_time_z
obs_dic['exposure_time'] = exposure_time
obs_dic['mode'] = 'MUSCAT_FAST'
obs_dic['guiding_config'] = 'ON'
obs_dic['diffuser_g_position'] = diffuser_g_position
obs_dic['diffuser_r_position'] = diffuser_r_position
obs_dic['diffuser_i_position'] = diffuser_i_position
obs_dic['diffuser_z_position'] = diffuser_z_position

obs_dic ['diffuser_g_position'] = diffuser_g_position
obs_dic ['diffuser_r_position'] = diffuser_r_position
obs_dic ['diffuser_i_position'] = diffuser_i_position
obs_dic ['diffuser_z_position'] = diffuser_z_position

obs_dic['guider_mode'] = 'ON'
obs_dic['exposure_mode'] = 'ASYNCHRONOUS'

obs_dic['period'] = cadence
obs_dic['jitter'] = jitter
Expand All @@ -458,7 +456,7 @@ def build_and_submit_muscat(target, obs_type):
obs_dic['proposal'] = proposal
obs_dic['instrument_type'] = instrument_type
obs_dic['facility'] = facility
obs_dic['type'] = type



request_obs = lco.LCOMuscatImagingObservationForm(obs_dic)
Expand Down
2 changes: 2 additions & 0 deletions mop/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@
urlpatterns = [
path('targets/<int:pk>/', MOPTargetDetailView.as_view(), name='detail'),
path('', include('tom_common.urls')),
path('productivity/', include(('productivity.urls', 'productivity'), namespace='productivity')),
path('time-alloc/', include(('time-alloc.urls', 'time-alloc'), namespace='time-alloc'))
]
50 changes: 50 additions & 0 deletions mop/views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
from django.shortcuts import redirect
from django.urls import reverse
from django.core.management import call_command
from django.views.generic import TemplateView
from django.shortcuts import render
from io import StringIO
from plotly.graph_objs import Scatter
import plotly.offline as opy
import plotly.graph_objs as go
from tom_observations.models import Target
from tom_targets.views import TargetDetailView


Expand All @@ -28,3 +34,47 @@ def get(self, request, *args, **kwargs):
call_command('run_TAP', target_name, stdout=out)
return redirect(reverse('tom_targets:detail', args=(target_id,)))
return super().get(request, *args, **kwargs)

class ProductivityView(TemplateView):
template_name = 'productivity.html'

def get_context_data(self, **kwargs):
context = super(ProductivityView, self).get_context_data(**kwargs)

x = [-2,-1,0,1,2]
y = [1, 1, 1, 1, 1]
y1 = [2, 2, 2, 2, 2]
y2 = [3, 3, 3, 3, 3]
#Easy to make multiple plot lines if they are all in a pandas dataframe
#Make the colors by observatory name, but plot by stage: Not Executed, Executed, and Pending

layout=go.Layout(title="Reqs vs Obs", xaxis={'title':'Date'}, yaxis={'title':''},
template='simple_white')
fig = go.Figure(layout=layout) #color='name of the observatory column')

# Add traces
fig.add_trace(go.Scatter(x=x, y=y,
mode='markers',
marker={'color': 'red', 'symbol': 100, 'size': 10},
name='Not Executed'))
fig.add_trace(go.Scatter(x=x, y=y1,
mode='markers',
marker={'color': 'green', 'symbol': 0, 'size': 10},
name='Executed'))
fig.add_trace(go.Scatter(x=x, y=y2,
mode='markers',
marker={'color': 'blue', 'symbol': 117, 'size': 10},
name='Pending'))


div = opy.plot(fig, auto_open=False, output_type='div')

context['graph'] = div

return context

class TimeAllocView(TemplateView):
template_name = 'time-alloc.html'

def get_context_data(self, **kwargs):
return {'targets': Target.objects.all()}
8 changes: 8 additions & 0 deletions productivity/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.urls import path, include
from django.views.generic import TemplateView
from mop.views import ProductivityView

urlpatterns = [
path('', include('tom_common.urls')),
path('productivity/', ProductivityView.as_view(), name='productivity')
]
15 changes: 15 additions & 0 deletions templates/productivity.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% extends 'tom_common/base.html' %}
{% block content %}
<html>
<head>
<title>Test Plot</title>
</head>
<body>
{% if graph %}
<div style="width:600;height:500">
{{ graph|safe }}
</div>
{% endif %}
</body>
</html>
{% endblock %}
12 changes: 12 additions & 0 deletions templates/time-alloc.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% extends 'tom_common/base.html' %}
{% block content %}
<p>
I would like to replace this with a template tag or a list template,
but it seems to be crashing at the moment :/
</p>
<ul>
{% for target in targets %}
<li>{{ target.name }}</li>
{% endfor %}
</ul>
{% endblock %}
27 changes: 24 additions & 3 deletions templates/tom_common/navbar_content.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<li class="nav-item {% if request.resolver_match.url_name == 'home' %}active{% endif %}">
<a class="nav-link" href="/">Home <span class="sr-only">(current)</span></a>
</li>

<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-toggle="dropdown">Targets</a>
<ul class="dropdown-menu">
Expand All @@ -22,12 +21,34 @@
<li class="nav-item {% if request.resolver_match.namespace == 'alerts' %}active{% endif %}">
<a class="nav-link" href="{% url 'alerts:list' %}">Alerts</a>
</li>
<li class="nav-item {% if request.resolver_match.namespace == 'observations' %}active{% endif %}">
<a class="nav-link" href="{% url 'tom_observations:list' %}">Requested Observations</a>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-toggle="dropdown">Observations</a>
<ul class="dropdown-menu">
<li class="nav-item {% if request.resolver_match.namespace == 'observations' %}active{% endif %}">
<a class="nav-link" href="{% url 'tom_observations:list' %}" style="color:black">Observations</a>
</li>
<li class="nav-item {% if request.resolver_match.namespace == 'observations' %}active{% endif %}">
<a class="nav-link" href="{% url 'tom_observations:group-list' %}" style="color:black">Observation Groups</a>
</li>
<li class="nav-item {% if request.resolver_match.namespace == 'observations' %}active{% endif %}">
<a class="nav-link" href="{% url 'tom_observations:template-list' %}" style="color:black">Observation Templates</a>
</li>
</ul>
</li>
<li class="nav-item {% if request.resolver_match.namespace == 'dataproducts' %}active{% endif %}">
<a class="nav-link" href="{% url 'tom_dataproducts:list' %}">Data</a>
</li>
<li class="nav-item {% if 'user' in request.resolver_match.url_name %}active{% endif %}">
<a class="nav-link" href="{% url 'user-list' %}">Users</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-toggle="dropdown">Project Status</a>
<ul class="dropdown-menu">
<li class="nav-item {% if request.resolver_match.namespace == 'time-alloc' %}active{% endif %}">
<a class="nav-link" href="{% url 'time-alloc:time-alloc' %}"><font color="black">Time Allocations</font></a>
</li>
<li class="nav-item {% if request.resolver_match.namespace == 'productivity' %}active{% endif %}">
<a class="nav-link" href="{% url 'productivity:productivity' %}"><font color="black">Reqs vs Obs</font></a>
</li>
</ul>
</li>
8 changes: 8 additions & 0 deletions time-alloc/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.urls import path, include
from django.views.generic import TemplateView
from mop.views import TimeAllocView

urlpatterns = [
path('', include('tom_common.urls')),
path('time-alloc/', TimeAllocView.as_view(), name='time-alloc')
]