Skip to content

Commit

Permalink
Merge pull request #109 from LCOGT/update/analysis-view-improvements
Browse files Browse the repository at this point in the history
Analysis data improvements
  • Loading branch information
LTDakin authored Nov 4, 2024
2 parents 63ec1bd + 75e6e05 commit 362cf69
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/components/Global/ImageGrid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const handleClick = (index) => {
const handleDoubleClick = (image) => {
clearTimeout(doubleClickTimer)
alertsStore.setAlert('loading', `Opening ${image?.basename} for analysis`)
alertsStore.setAlert('info', `Opening ${image?.basename} for analysis`)
launchAnalysis(image)
}
Expand Down
97 changes: 82 additions & 15 deletions src/components/Project/ImageAnalysis/ImageAnalyzer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
import { ref } from 'vue'
import { fetchApiCall } from '../../../utils/api'
import { useConfigurationStore } from '@/stores/configuration'
import { useAlertsStore } from '@/stores/alerts'
import ImageViewer from './ImageViewer.vue'
import LinePlot from './LinePlot.vue'
import FilterBadge from '@/components/Global/FilterBadge.vue'
import ImageDownloadMenu from '@/components/Project/ImageAnalysis/ImageDownloadMenu.vue'
import { siteIDToName } from '@/utils/common'
const props = defineProps({
modelValue: {
Expand All @@ -20,19 +22,23 @@ const props = defineProps({
})
const emit = defineEmits(['update:modelValue'])
const configStore = useConfigurationStore()
const alertsStore = useAlertsStore()
const lineProfile = ref([])
const lineProfileLength = ref()
const startCoords = ref()
const endCoords = ref()
const catalog = ref([])
const positionAngle = ref()
const headerDialog = ref(false)
const headerData = ref({})
function closeDialog() {
lineProfile.value = []
lineProfileLength.value = 0
startCoords.value = null
endCoords.value = null
headerData.value = null
emit('update:modelValue', false)
}
Expand Down Expand Up @@ -68,6 +74,26 @@ function handleAnalysisOutput(response, action, action_callback){
}
}
function showHeaderDialog() {
if(headerData.value && Object.keys(headerData.value).length > 0) {
headerDialog.value = true
return
}
const archiveHeadersUrl = configStore.datalabArchiveApiUrl + 'frames/' + props.image.id + '/headers/'
fetchApiCall({url: archiveHeadersUrl, method: 'GET',
successCallback: (response) => {
headerData.value = response.data
headerDialog.value = true
},
failCallback: (error) => {
console.error('Failed to fetch headers:', error)
alertsStore.setAlert('error', `Could not fetch headers for frame ${props.image.id}`)
}
})
}
</script>
<template>
<v-dialog
Expand All @@ -78,12 +104,21 @@ function handleAnalysisOutput(response, action, action_callback){
<v-toolbar
class="analysis-toolbar"
density="comfortable"
:title="image.target_name || 'N/A'"
>
<filter-badge
v-if="image.FILTER || image.filter"
:filter="image.FILTER || image.filter"
class="ml-2"
/>
<v-toolbar-title>{{ image.basename || "Unknown" }}</v-toolbar-title>
<image-download-menu
:image="image"
@analysis-action="requestAnalysis"
/>
<v-btn
icon="mdi-information"
@click="showHeaderDialog"
/>
<v-btn
icon="mdi-close"
@click="closeDialog()"
Expand All @@ -96,19 +131,15 @@ function handleAnalysisOutput(response, action, action_callback){
@analysis-action="requestAnalysis"
/>
<div class="side-panel-container">
<v-sheet class="side-panel">
<h1>Details</h1>
<p>Basename: {{ image.basename }}</p>
<p>Date & Time: {{ image.observation_date }}</p>
<p>Site: {{ image.site_id }}</p>
<p>Telescope: {{ image.telescope_id }}</p>
<p>Instrument: {{ image.instrument_id }}</p>
<span>Filter:
<filter-badge
v-if="image.FILTER || image.filter"
:filter="image.FILTER || image.filter"
/>
</span>
<v-sheet
v-if="image.site_id || image.telescope_id || image.instrument_id || image.observation_date"
rounded
class="side-panel"
>
<p><v-icon icon="mdi-earth" /> {{ siteIDToName(image.site_id) ?? 'Missing Site' }}</p>
<p><v-icon icon="mdi-telescope" /> {{ image.telescope_id ?? 'Missing Telescope ID' }}</p>
<p><v-icon icon="mdi-camera" /> {{ image.instrument_id ?? 'Missing Instrument ID' }} </p>
<p><v-icon icon="mdi-clock" /> {{ new Date(image.observation_date).toLocaleString() }}</p>
</v-sheet>
<line-plot
:y-axis-luminosity="lineProfile"
Expand All @@ -121,11 +152,47 @@ function handleAnalysisOutput(response, action, action_callback){
</div>
</v-sheet>
</v-dialog>
<v-dialog
v-model="headerDialog"
width="auto"
>
<v-sheet class="pa-12">
<h1 class="mb-8">
FITS Headers
</h1>
<v-table>
<tbody>
<tr
v-for="(value, key) in headerData"
:key="key"
>
<td class="table_key">
{{ key }}
</td>
<td>{{ value }}</td>
</tr>
</tbody>
</v-table>
</v-sheet>
</v-dialog>
</template>
<style scoped>
a{
color: var(--tan);
}
.v-sheet{
background-color: var(--metal);
color: var(--tan);
}
.v-table{
background-color: var(--metal);
color: var(--tan);
max-width: 60ch;
}
.table_key{
font-weight: bold;
font-size: large;
}
.analysis-sheet{
background-color: var(--dark-blue);
font-family: 'Open Sans', sans-serif;
Expand All @@ -146,7 +213,7 @@ a{
flex-direction: column
}
.side-panel{
background-color: var(--dark-blue);
padding: 1rem;
color: var(--tan);
margin-left: 10px;
margin-bottom: 5%;
Expand Down
6 changes: 5 additions & 1 deletion src/components/Project/ImageList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ref, computed, defineProps } from 'vue'
import { useThumbnailsStore } from '@/stores/thumbnails'
import { useAlertsStore } from '@/stores/alerts'
import { useConfigurationStore } from '@/stores/configuration'
import { siteIDToName } from '@/utils/common'
import FilterBadge from '@/components/Global/FilterBadge.vue'
import ImageAnalyzer from '../Project/ImageAnalysis/ImageAnalyzer.vue'
Expand Down Expand Up @@ -53,7 +54,7 @@ function select(tableSelectedImages){
function launchAnalysis(image){
try {
alertsStore.setAlert('loading', `Opening ${image?.basename} for analysis`)
alertsStore.setAlert('info', `Opening ${image?.basename} for analysis`)
if (!image.largeCachedUrl) {
image.largeCachedUrl = ref('')
const url = image.large_url || image.largeThumbUrl || ''
Expand Down Expand Up @@ -94,6 +95,9 @@ function launchAnalysis(image){
<template #[`item.observation_date`]="{ item }">
<p>{{ new Date(item.observation_date).toLocaleString() }}</p>
</template>
<template #[`item.site_id`]="{ item }">
<p>{{ siteIDToName(item.site_id) }}</p>
</template>
<template #[`item.FILTER`]="{ item }">
<filter-badge
v-if="item.FILTER"
Expand Down
2 changes: 1 addition & 1 deletion src/stores/alerts.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { defineStore } from 'pinia'
export const useAlertsStore = defineStore('alerts', {
state() {
return{
alertType: 'default', // alert type to display ('success', 'error', 'warning', 'info', 'loading')
alertType: 'info', // alert type to display ('success', 'error', 'warning', 'info')
alertText: 'default alert text', // text displayed in alert
alertTimeStamp: '0' // timestamp of the last alert, used for watching in AlertToast.vue
}
Expand Down
17 changes: 16 additions & 1 deletion src/utils/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@ const calculateColumnSpan = (imageCount, imagesPerRow) => {
return totalColumns
}

function siteIDToName(siteID) {
const siteIDMap = {
'COJ': 'Siding Spring Observatory @ New South Wales',
'CPT': 'South African Astronomical Observatory @ Cape Town',
'TFN': 'Teide Observatory @ Tenerife',
'LSC': 'Cerro Tololo Inter-American Observatory @ Chile',
'ELP': 'McDonald Observatory @ University of Texas',
'OGG': 'Haleakala Observatory @ Maui',
'TLV': 'Wise Observatory @ Tel Aviv University',
'NGQ': 'Ali Observatory @ Tibet',
}

return siteIDMap[siteID?.toUpperCase()] || siteID
}

function initializeDate(dateString = 'none', defaultOffsetDays = 0) {
/**
* Initialize a date object from a string
Expand All @@ -15,4 +30,4 @@ function initializeDate(dateString = 'none', defaultOffsetDays = 0) {
return isNaN(date.getTime()) ? new Date(Date.now() + defaultOffsetDays * 24 * 3600 * 1000) : date
}

export { calculateColumnSpan, initializeDate }
export { calculateColumnSpan, siteIDToName, initializeDate }

0 comments on commit 362cf69

Please sign in to comment.