From 0a3e624c72a7cd8411f82c1dd785697c31762401 Mon Sep 17 00:00:00 2001 From: Masato Onodera Date: Fri, 24 May 2024 14:59:53 -1000 Subject: [PATCH 1/2] add single_exptime in the target table --- ..._add_single_exptime_to_the_target_table.py | 28 +++++++++++++++ ...c2966c63_set_single_exptime_un_nullable.py | 34 +++++++++++++++++++ src/targetdb/models/target.py | 9 +++++ 3 files changed, 71 insertions(+) create mode 100644 alembic/pfsa-db01-gb/alembic/versions/20240524-145050_f630d28235eb_add_single_exptime_to_the_target_table.py create mode 100644 alembic/pfsa-db01-gb/alembic/versions/20240524-145817_1027c2966c63_set_single_exptime_un_nullable.py diff --git a/alembic/pfsa-db01-gb/alembic/versions/20240524-145050_f630d28235eb_add_single_exptime_to_the_target_table.py b/alembic/pfsa-db01-gb/alembic/versions/20240524-145050_f630d28235eb_add_single_exptime_to_the_target_table.py new file mode 100644 index 0000000..1d268f2 --- /dev/null +++ b/alembic/pfsa-db01-gb/alembic/versions/20240524-145050_f630d28235eb_add_single_exptime_to_the_target_table.py @@ -0,0 +1,28 @@ +"""Add single_exptime to the target table + +Revision ID: f630d28235eb +Revises: 368dce443754 +Create Date: 2024-05-24 14:50:50.589144 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'f630d28235eb' +down_revision = '368dce443754' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('target', sa.Column('single_exptime', sa.Float(), nullable=True, comment='Individual exposure time (s)')) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('target', 'single_exptime') + # ### end Alembic commands ### diff --git a/alembic/pfsa-db01-gb/alembic/versions/20240524-145817_1027c2966c63_set_single_exptime_un_nullable.py b/alembic/pfsa-db01-gb/alembic/versions/20240524-145817_1027c2966c63_set_single_exptime_un_nullable.py new file mode 100644 index 0000000..4f75e40 --- /dev/null +++ b/alembic/pfsa-db01-gb/alembic/versions/20240524-145817_1027c2966c63_set_single_exptime_un_nullable.py @@ -0,0 +1,34 @@ +"""set single_exptime un-nullable + +Revision ID: 1027c2966c63 +Revises: f630d28235eb +Create Date: 2024-05-24 14:58:17.757023 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '1027c2966c63' +down_revision = 'f630d28235eb' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column('target', 'single_exptime', + existing_type=sa.DOUBLE_PRECISION(precision=53), + nullable=False, + existing_comment='Individual exposure time (s)') + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column('target', 'single_exptime', + existing_type=sa.DOUBLE_PRECISION(precision=53), + nullable=True, + existing_comment='Individual exposure time (s)') + # ### end Alembic commands ### diff --git a/src/targetdb/models/target.py b/src/targetdb/models/target.py index 06d9b89..d279fd1 100644 --- a/src/targetdb/models/target.py +++ b/src/targetdb/models/target.py @@ -187,6 +187,13 @@ class target(Base): Float, nullable=False, comment="Requested effective exposure time (s)" ) + single_exptime = Column( + Float, + nullable=False, + default=900, + comment="Individual exposure time (s)", + ) + is_medium_resolution = Column( Boolean, default=False, @@ -298,6 +305,7 @@ def __init__( # priority, effective_exptime, + single_exptime, is_medium_resolution, # qa_relative_throughput, @@ -364,6 +372,7 @@ def __init__( # self.priority = priority self.effective_exptime = effective_exptime + self.single_exptime = single_exptime self.is_medium_resolution = is_medium_resolution # self.qa_relative_throughput = qa_relative_throughput From 07f2154afb2bd536f4fc41cca1d5f29fd2ab531e Mon Sep 17 00:00:00 2001 From: Masato Onodera Date: Fri, 24 May 2024 15:18:43 -1000 Subject: [PATCH 2/2] document update on single_exptime --- docs/schema/target.md | 1 + docs/tbls/README.md | 3 ++- docs/tbls/public.cluster.md | 1 + docs/tbls/public.filter_name.md | 1 + docs/tbls/public.fluxstd.md | 2 +- docs/tbls/public.input_catalog.md | 1 + docs/tbls/public.proposal.md | 1 + docs/tbls/public.target.md | 2 ++ docs/tbls/public.target_type.md | 1 + 9 files changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/schema/target.md b/docs/schema/target.md index fad9d35..4ac97e4 100644 --- a/docs/schema/target.md +++ b/docs/schema/target.md @@ -62,6 +62,7 @@ Here are the columns in the `target` table: | filter_j | str | Photometric band used to measure the PSF flux in _j_-band | | (\*) | | | priority | float | Priority of the target for observation. | | | 1.0 | | effective_exptime | float | Effective exposure time required to complete the target | s | \* | | +| single_exptime | float | Individual exposure time | s | | 900 | | is_medium_resolution | bool | `True` if the target is observed with the medium-resolution mode | | | False | | qa_relative_throughput | float | Quality assurance metric for relative throughput. | | | 1.0 | | qa_relative_noise | float | Quality assurance metric for relative noise. | | | 1.0 | diff --git a/docs/tbls/README.md b/docs/tbls/README.md index 0ae8b5d..7553571 100644 --- a/docs/tbls/README.md +++ b/docs/tbls/README.md @@ -11,7 +11,7 @@ | [public.proposal](public.proposal.md) | 13 | | BASE TABLE | | [public.sky](public.sky.md) | 14 | | BASE TABLE | | [public.fluxstd](public.fluxstd.md) | 61 | | BASE TABLE | -| [public.target](public.target.md) | 59 | | BASE TABLE | +| [public.target](public.target.md) | 60 | | BASE TABLE | | [public.cluster](public.cluster.md) | 10 | | BASE TABLE | ## Stored procedures and functions @@ -257,6 +257,7 @@ erDiagram varchar filter_j FK double_precision priority double_precision effective_exptime + double_precision single_exptime boolean is_medium_resolution double_precision qa_relative_throughput double_precision qa_relative_noise diff --git a/docs/tbls/public.cluster.md b/docs/tbls/public.cluster.md index 127fb98..7a37314 100644 --- a/docs/tbls/public.cluster.md +++ b/docs/tbls/public.cluster.md @@ -104,6 +104,7 @@ erDiagram varchar filter_j FK double_precision priority double_precision effective_exptime + double_precision single_exptime boolean is_medium_resolution double_precision qa_relative_throughput double_precision qa_relative_noise diff --git a/docs/tbls/public.filter_name.md b/docs/tbls/public.filter_name.md index 66838e5..ebdb9f4 100644 --- a/docs/tbls/public.filter_name.md +++ b/docs/tbls/public.filter_name.md @@ -163,6 +163,7 @@ erDiagram varchar filter_j FK double_precision priority double_precision effective_exptime + double_precision single_exptime boolean is_medium_resolution double_precision qa_relative_throughput double_precision qa_relative_noise diff --git a/docs/tbls/public.fluxstd.md b/docs/tbls/public.fluxstd.md index c1b6a36..5d28f00 100644 --- a/docs/tbls/public.fluxstd.md +++ b/docs/tbls/public.fluxstd.md @@ -89,8 +89,8 @@ | ---- | ---------- | | fluxstd_pkey | CREATE UNIQUE INDEX fluxstd_pkey ON public.fluxstd USING btree (fluxstd_id) | | uq_obj_id_input_catalog_id_version | CREATE UNIQUE INDEX uq_obj_id_input_catalog_id_version ON public.fluxstd USING btree (obj_id, input_catalog_id, version) | -| fluxstd_q3c_ang2ipix_idx | CREATE INDEX fluxstd_q3c_ang2ipix_idx ON public.fluxstd USING btree (q3c_ang2ipix(ra, "dec")) | | ix_fluxstd_version | CREATE INDEX ix_fluxstd_version ON public.fluxstd USING btree (version) | +| fluxstd_q3c_ang2ipix_idx | CREATE INDEX fluxstd_q3c_ang2ipix_idx ON public.fluxstd USING btree (q3c_ang2ipix(ra, "dec")) | ## Relations diff --git a/docs/tbls/public.input_catalog.md b/docs/tbls/public.input_catalog.md index 2f13a93..bba9236 100644 --- a/docs/tbls/public.input_catalog.md +++ b/docs/tbls/public.input_catalog.md @@ -177,6 +177,7 @@ erDiagram varchar filter_j FK double_precision priority double_precision effective_exptime + double_precision single_exptime boolean is_medium_resolution double_precision qa_relative_throughput double_precision qa_relative_noise diff --git a/docs/tbls/public.proposal.md b/docs/tbls/public.proposal.md index d608073..8151a9e 100644 --- a/docs/tbls/public.proposal.md +++ b/docs/tbls/public.proposal.md @@ -109,6 +109,7 @@ erDiagram varchar filter_j FK double_precision priority double_precision effective_exptime + double_precision single_exptime boolean is_medium_resolution double_precision qa_relative_throughput double_precision qa_relative_noise diff --git a/docs/tbls/public.target.md b/docs/tbls/public.target.md index 190e7b0..210bca0 100644 --- a/docs/tbls/public.target.md +++ b/docs/tbls/public.target.md @@ -58,6 +58,7 @@ | filter_j | varchar | | true | | [public.filter_name](public.filter_name.md) | j-band filter (j_mko, etc.) | | priority | double precision | | true | | | Priority of the target specified by the observer within the proposal | | effective_exptime | double precision | | false | | | Requested effective exposure time (s) | +| single_exptime | double precision | | false | | | Individual exposure time (s) | | is_medium_resolution | boolean | | true | | | True if the medium resolution mode is requested | | qa_relative_throughput | double precision | | true | | | Relative throughput to the reference value requested by the observer (default: 1.0) | | qa_relative_noise | double precision | | true | | | Relative noise to the reference value requested by the observer (default: 1.0) | @@ -161,6 +162,7 @@ erDiagram varchar filter_j FK double_precision priority double_precision effective_exptime + double_precision single_exptime boolean is_medium_resolution double_precision qa_relative_throughput double_precision qa_relative_noise diff --git a/docs/tbls/public.target_type.md b/docs/tbls/public.target_type.md index ec5de1f..fd279b1 100644 --- a/docs/tbls/public.target_type.md +++ b/docs/tbls/public.target_type.md @@ -172,6 +172,7 @@ erDiagram varchar filter_j FK double_precision priority double_precision effective_exptime + double_precision single_exptime boolean is_medium_resolution double_precision qa_relative_throughput double_precision qa_relative_noise