Skip to content

Commit

Permalink
implement api hints across all plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
kecnry committed Oct 17, 2024
1 parent f94637b commit 17c36be
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 42 deletions.
8 changes: 5 additions & 3 deletions lcviz/components/plugin_ephemeris_select.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<template>
<div>
<v-row v-if="items.length > 1 || show_if_single_entry">
<v-row v-if="items.length > 1 || show_if_single_entry || api_hints_enabled">
<v-select
:menu-props="{ left: true }"
attach
:items="items"
v-model="selected"
@change="$emit('update:selected', $event)"
:label="label ? label : 'Ephemeris'"
:label="api_hints_enabled && api_hint ? api_hint : (label ? label : 'Ephemeris')"
:class="api_hints_enabled ? 'api-hint' : null"
:hint="hint ? hint : 'Select ephemeris.'"
:rules="rules ? rules : []"
item-text="label"
Expand All @@ -34,7 +35,8 @@
</template>
<script>
module.exports = {
props: ['items', 'selected', 'label', 'hint', 'rules', 'show_if_single_entry']
props: ['items', 'selected', 'label', 'hint', 'rules', 'show_if_single_entry',
'api_hint', 'api_hints_enabled']
};
</script>

Expand Down
19 changes: 15 additions & 4 deletions lcviz/plugins/binning/binning.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<template>
<j-tray-plugin
:config="config"
plugin_key="Binning"
:api_hints_enabled.sync="api_hints_enabled"
description='Bin in time or phase-space.'
:link="'https://lcviz.readthedocs.io/en/'+vdocs+'/plugins.html#binning'"
:uses_active_status="uses_active_status"
Expand All @@ -15,12 +18,14 @@
</v-expansion-panel-header>
<v-expansion-panel-content>
<v-row>
<v-switch
v-model="show_live_preview"
<plugin-switch
:value.sync="show_live_preview"
label="Show live preview"
api_hint="plg.show_live_preview ="
:api_hints_enabled="api_hints_enabled"
hint="Whether to show live preview of binning options."
persistent-hint
></v-switch>
/>
</v-row>
</v-expansion-panel-content>
</v-expansion-panel>
Expand All @@ -32,6 +37,8 @@
:selected.sync="dataset_selected"
:show_if_single_entry="false"
label="Data"
api_hint="plg.dataset ="
:api_hints_enabled="api_hints_enabled"
hint="Select the light curve as input."
/>

Expand All @@ -45,7 +52,8 @@

<v-row>
<v-text-field
label="N Bins"
:label="api_hints_enabled ? 'plg.n_bins =' : 'N Bins'"
:class="api_hints_enabled ? 'api-hint' : null"
type="number"
v-model.number="n_bins"
:step="10"
Expand Down Expand Up @@ -76,6 +84,9 @@
action_tooltip="Bin data"
:action_disabled="!bin_enabled"
:action_spinner="spinner"
add_results_api_hint = 'plg.add_results'
action_api_hint='plg.bin(add_data=True)'
:api_hints_enabled="api_hints_enabled"
@click:action="apply"
></plugin-add-results>

Expand Down
71 changes: 59 additions & 12 deletions lcviz/plugins/ephemeris/ephemeris.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<template>
<j-tray-plugin
:config="config"
plugin_key="Ephemeris"
:api_hints_enabled.sync="api_hints_enabled"
description='Find and refine ephemerides for phase-folding.'
:link="'https://lcviz.readthedocs.io/en/'+vdocs+'/plugins.html#ephemeris'"
:popout_button="popout_button">
Expand All @@ -10,13 +13,28 @@
:items="component_items"
:selected.sync="component_selected"
label="Component"
api_hint="plg.component ="
api_hint_add="plg.add_component"
api_hint_rename="plg.rename_component"
api_hint_remove="plg.remove_component"
:api_hints_enabled="api_hints_enabled"
hint="Select an ephemeris component."
>
</plugin-editable-select>

<v-row justify="end">
<v-btn color="primary" text @click="create_phase_viewer" :disabled="phase_viewer_exists || component_selected.length == 0">
Show Phase Viewer
<v-btn
color="primary"
text
:class="api_hints_enabled ? 'api-hint' : null"
@click="create_phase_viewer"
:disabled="phase_viewer_exists || component_selected.length == 0"
>
{{ api_hints_enabled ?
'plg.create_phase_viewer()'
:
'Show Phase Viewer'
}}
</v-btn>
</v-row>

Expand All @@ -27,7 +45,8 @@
<v-text-field
ref="t0"
type="number"
label="Zeropoint (t0)"
:label="api_hints_enabled ? 'plg.t0 =' : 'Zeropoint (t0)'"
:class="api_hints_enabled ? 'api-hint' : null"
v-model.number="t0"
:step="t0_step"
type="number"
Expand All @@ -41,7 +60,8 @@
<v-text-field
ref="period"
type="number"
label="Period"
:label="api_hints_enabled ? 'plg.period =' : 'Period'"
:class="api_hints_enabled ? 'api-hint' : null"
v-model.number="period"
:step="period_step"
hint="The period of the ephemeris, defined at t0."
Expand All @@ -64,7 +84,8 @@
<v-text-field
ref="dpdt"
type="number"
label="Period derivative"
:label="api_hints_enabled ? 'plg.dpdt =' : 'Period derivative'"
:class="api_hints_enabled ? 'api-hint' : null"
v-model.number="dpdt"
:step="dpdt_step"
hint="The first time-derivative of the period of the ephemeris."
Expand All @@ -77,7 +98,8 @@
<v-text-field
ref="wrap_at"
type="number"
label="Wrapping phase"
:label="api_hints_enabled ? 'plg.wrap_at =' : 'Wrapping phase'"
:class="api_hints_enabled ? 'api-hint' : null"
v-model.number="wrap_at"
:step="0.1"
:hint="'Phased data will encompass the range '+wrap_at_range+'.'"
Expand All @@ -93,6 +115,8 @@
:selected.sync="dataset_selected"
:show_if_single_entry="false"
label="Data"
api_hint="plg.dataset ="
:api_hints_enabled="api_hints_enabled"
hint="Select the light curve as input."
/>

Expand All @@ -102,7 +126,8 @@
attach
:items="method_items.map(i => i.label)"
v-model="method_selected"
label="Algorithm/Method"
:label="api_hints_enabled ? 'plg.method =' : 'Algorithm/Method'"
:class="api_hints_enabled ? 'api-hint' : null"
hint="Method to determine period."
persistent-hint
></v-select>
Expand All @@ -116,8 +141,19 @@
</v-row>
<v-row v-else>
<j-tooltip :tooltipcontent="'adopt period into '+component_selected+' ephemeris.'">
<v-btn text color='primary' @click='adopt_period_at_max_power' style="padding: 0px">
period: {{period_at_max_power}}
<v-btn
text
color='primary'
:class="api_hints_enabled ? 'api-hint' : null"
@click='adopt_period_at_max_power'
style="padding: 0px"
>
{{ api_hints_enabled ?
'plg.adopt_period_at_max_power()'
:
'period: '+period_at_max_power
}}

</v-btn>
</j-tooltip>
</v-row>
Expand Down Expand Up @@ -201,8 +237,13 @@
<plugin-action-button
:spinner="query_spinner"
:results_isolated_to_plugin="false"
:api_hints_enabled="api_hints_enabled"
@click="query_for_ephemeris">
Query
{{ api_hints_enabled ?
'plg.query_for_ephemeris()'
:
'Query'
}}
</plugin-action-button>
</j-tooltip>
</v-row>
Expand All @@ -214,7 +255,8 @@
:items="query_result_items"
:item-value="item => item.label"
v-model="query_result_selected"
label="Ephemerides available"
:label="api_hints_enabled ? 'plg.query_result =' : 'Ephemerides available'"
:class="api_hints_enabled ? 'api-hint' : null"
:hint="'Ephemeris parameters from ' + query_result_items.length + ' available query result(s)'"
persistent-hint
dense
Expand Down Expand Up @@ -246,8 +288,13 @@
<v-col>
<plugin-action-button
@click="create_ephemeris_from_query"
:class="api_hints_enabled ? 'api-hint' : null"
:disabled="component_items.map(item => item.label).includes(query_result_selected.replace(/\s/g, ''))">
Create new component
{{ api_hints_enabled ?
'plg.create_ephemeris_from_query()'
:
'Create new component'
}}
</plugin-action-button>
</v-col>
</v-row>
Expand Down
53 changes: 38 additions & 15 deletions lcviz/plugins/flatten/flatten.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<template>
<j-tray-plugin
:config="config"
plugin_key="Flatten"
:api_hints_enabled.sync="api_hints_enabled"
description='Remove long-term trends.'
:link="'https://lcviz.readthedocs.io/en/'+vdocs+'/plugins.html#flatten'"
:uses_active_status="uses_active_status"
Expand All @@ -15,23 +18,27 @@
</v-expansion-panel-header>
<v-expansion-panel-content>
<v-row>
<v-switch
v-model="show_live_preview"
<plugin-switch
:value.sync="show_live_preview"
api_hint="plg.show_live_preview ="
:api_hints_enabled="api_hints_enabled"
label="Show flattened preview"
hint="Whether to show live-preview of the unnormalized flattened light curve."
persistent-hint
></v-switch>
/>
</v-row>
<v-row v-if="show_live_preview && !unnormalize">
<v-alert type="warning">Live preview is unnormalized, but flattening will normalize.</v-alert>
</v-row>
<v-row>
<v-switch
v-model="show_trend_preview"
<plugin-switch
:value.sync="show_trend_preview"
api_hint="plg.show_trend_preview ="
:api_hints_enabled="api_hints_enabled"
label="Show trend preview"
hint="Whether to show live-preview of the trend used for flattening."
persistent-hint
></v-switch>
/>
</v-row>
</v-expansion-panel-content>
</v-expansion-panel>
Expand All @@ -43,12 +50,15 @@
:selected.sync="dataset_selected"
:show_if_single_entry="false"
label="Data"
api_hint="plg.dataset ="
:api_hints_enabled="api_hints_enabled"
hint="Select the light curve as input."
/>

<v-row>
<v-text-field
label="Window length"
:label="api_hints_enabled ? 'plg.window_length =' : 'Window length'"
:class="api_hints_enabled ? 'api-hint' : null"
type="number"
:step="1"
v-model.number="window_length"
Expand All @@ -62,7 +72,8 @@

<v-row>
<v-text-field
label="Order"
:label="api_hints_enabled ? 'plg.polyorder =' : 'Order'"
:class="api_hints_enabled ? 'api-hint' : null"
type="number"
:step="1"
v-model.number="polyorder"
Expand All @@ -77,7 +88,8 @@

<v-row>
<v-text-field
label="Break tolerance"
:label="api_hints_enabled ? 'plg.break_tolerance =' : 'Break tolerance'"
:class="api_hints_enabled ? 'api-hint' : null"
type="number"
:step="1"
v-model.number="break_tolerance"
Expand All @@ -91,7 +103,8 @@

<v-row>
<v-text-field
label="Iterations"
:label="api_hints_enabled ? 'plg.niters =' : 'Iterations'"
:class="api_hints_enabled ? 'api-hint' : null"
type="number"
:step="1"
v-model.number="niters"
Expand All @@ -105,7 +118,8 @@

<v-row>
<v-text-field
label="Sigma"
:label="api_hints_enabled ? 'plg.sigma =' : 'Sigma'"
:class="api_hints_enabled ? 'api-hint' : null"
type="number"
:step="0.5"
v-model.number="sigma"
Expand All @@ -118,12 +132,14 @@
</v-row>

<v-row>
<v-switch
v-model="unnormalize"
<plugin-switch
:value.sync="unnormalize"
label="Un-normalize"
api_hint="plg.unnormalize ="
:api_hints_enabled="api_hints_enabled"
hint="Whether to multiply the flattened light curve by the median of the trend."
persistent-hint
></v-switch>
/>
</v-row>

<v-row v-if="show_live_preview && !unnormalize">
Expand All @@ -136,6 +152,8 @@
:auto.sync="flux_label_auto"
:invalid_msg="flux_label_invalid_msg"
hint="Label for flux column."
api_hint="plg.flux_label ="
:api_hints_enabled="api_hints_enabled"
></plugin-auto-label>

<plugin-previews-temp-disabled
Expand All @@ -151,8 +169,13 @@
:spinner="spinner"
:disabled="flux_label_invalid_msg.length > 0"
:results_isolated_to_plugin="false"
:class="api_hints_enabled ? 'api-hint' : null"
@click="apply">
Flatten{{flux_label_overwrite ? ' (Overwrite)' : ''}}
{{ api_hints_enabled ?
'plg.flatten(add_data=True)'
:
'Flatten'+(flux_label_overwrite ? ' (Overwrite)' : '')
}}
</plugin-action-button>
</j-tooltip>
</v-row>
Expand Down
Loading

0 comments on commit 17c36be

Please sign in to comment.