Skip to content
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

API hints #133

Merged
merged 3 commits into from
Oct 17, 2024
Merged
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
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
0.5.0 (unreleased)
------------------

* Update jdaviz requirement to 4.0 to include upstream improvements. [#121]
* Update jdaviz requirement to 4.0 to include upstream improvements including API hints. [#121, #133]

* Prevent duplicate sub-intervals (quarter/sector/campaign) in data labels. [#120]

Expand Down
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
5 changes: 3 additions & 2 deletions lcviz/plugins/ephemeris/ephemeris.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,9 @@ def user_api(self):
'add_component', 'remove_component', 'rename_component',
'times_to_phases', 'phases_to_times', 'get_data',
'dataset', 'method', 'period_at_max_power',
'adopt_period_at_max_power', 'query_for_ephemeris',
'query_result', 'create_ephemeris_from_query'
'adopt_period_at_max_power',
'query_name', 'query_ra', 'query_dec', 'query_radius',
'query_for_ephemeris', 'query_result', 'create_ephemeris_from_query'
]
return PluginUserApi(self, expose=expose)

Expand Down
83 changes: 67 additions & 16 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 @@ -156,7 +192,8 @@
<v-text-field
ref="query_name"
type="string"
label="Object name"
:label="api_hints_enabled ? 'plg.query_name =' : 'Object name'"
:class="api_hints_enabled ? 'api-hint' : null"
v-model.number="query_name"
hint="Object name."
persistent-hint
Expand All @@ -166,7 +203,8 @@
<v-text-field
ref="query_ra"
type="number"
label="RA (degrees)"
:label="api_hints_enabled ? 'plg.query_ra =' : 'RA (degrees)'"
:class="api_hints_enabled ? 'api-hint' : null"
v-model.number="query_ra"
:step="ra_dec_step"
hint="Object right ascension."
Expand All @@ -177,7 +215,8 @@
<v-text-field
ref="query_dec"
type="number"
label="Dec (degrees)"
:label="api_hints_enabled ? 'plg.query_dec =' : 'Dec (degrees)'"
:class="api_hints_enabled ? 'api-hint' : null"
v-model.number="query_dec"
:step="ra_dec_step"
hint="Object declination."
Expand All @@ -188,7 +227,8 @@
<v-text-field
ref="query_radius"
type="number"
label="Radius (arcseconds)"
:label="api_hints_enabled ? 'plg.query_radius =' : 'Radius (arcseconds)'"
:class="api_hints_enabled ? 'api-hint' : null"
v-model.number="query_radius"
:step="1"
hint="Radius around the query coordinate."
Expand All @@ -201,8 +241,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'
}}
Comment on lines +246 to +250
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You got the query_for_ephemeris method for this portion of the plugin, but not the name/RA/Dec/radius fields above:

Screenshot 2024-08-21 at 14 44 28

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, you didn't expose those to the API in #127 😝 Do you want me to add them here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are now exposed in the API and hints added in this PR.

</plugin-action-button>
</j-tooltip>
</v-row>
Expand All @@ -214,7 +259,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 +292,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
Loading