Skip to content

Commit

Permalink
#None: v0.4.7
Browse files Browse the repository at this point in the history
See changes in RELEASE_NOTES
  • Loading branch information
mickolaua committed Feb 19, 2024
1 parent 65d0ee3 commit abda8ff
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 29 deletions.
8 changes: 8 additions & 0 deletions RELEASE_NOTES
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ In this minor release:

- Fixed problem with conical MOC creation with mocpy>0.12

## v0.4.7

- Fixed circular import in LVC plugin, when using AWARE in interactive mode
- Fixed visibility curve calculation, introduced in v0.4.4
- Added cache_ok=True flag for TelegramID type
- Use default naming convention for table constraints for easier migration
- Define declarative base in SQLAlchemy 2.0 style


# v0.3.0

Expand Down
2 changes: 1 addition & 1 deletion aware/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = ("0", "4", "6")
__version__ = ("0", "4", "7")
__strversion__ = "{}.{}.{}".format(__version__)
10 changes: 8 additions & 2 deletions aware/alert/plugins/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
__modules__ = ["gbm", "lvc", "swift", "integral", "icecube", "lat", "maxi"]

from .gbm import *
from .lvc import *
from .lvc import (
LVC_EARLY_WARNING_Parser,
LVC_INITIAL_Parser,
LVC_PRELIMINARY_Parser,
LVC_RETRACTION_Parser,
LVC_UPDATE_Parser,
)
from .swift import *
from .integral import *
from .icecube import *
from .lat import *
from .maxi import *
from .maxi import *
13 changes: 7 additions & 6 deletions aware/alert/plugins/lvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
from ..parser import AlertParser
from ..target_info import TargetInfo
from ...config import CfgOption, dev
from ..util import is_retracted
from ...util import download_file
from ...data import cache_dir
import aware.data
from ...topic import full_topic_name_to_short

__all__ = [
Expand All @@ -41,8 +40,8 @@


def is_observable_bbh(loc: LVCSkyMap) -> bool:
"""Is the localization of the BBH event should be observed? Here, we attempt to
find a likely possible optical transients occured due to the capture of the
"""Is the localization of the BBH event should be observed? Here, we attempt to
find a likely possible optical transients occured due to the capture of the
surrounding material to the merger of two black holes.
Parameters
Expand Down Expand Up @@ -129,7 +128,7 @@ def parse_lvc_alert(
-------
TargetInfo | None
The target info or None in case of a mock data event
"""
"""

rejected = True if topic == "gcn.classic.voevent.LVC_RETRACTION" else False

Expand Down Expand Up @@ -173,7 +172,9 @@ def parse_lvc_alert(
"Downloading HEALPix for LVK %s; try %d/%d", event_id, i, tries
)
unique = full_topic_name_to_short(topic).lower()
local_path = posixpath.join(cache_dir.value, f"lvc_{event_id}", unique)
local_path = posixpath.join(
aware.data.cache_dir.value, f"lvc_{event_id}", unique
)
os.makedirs(local_path, exist_ok=True)
status = download_file(healpix_url, path=local_path, timeout=timeout)
filename = posixpath.split(healpix_url)[1]
Expand Down
2 changes: 1 addition & 1 deletion aware/site/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def observable_targets(
else:
night_duration = end_time.jd - start_time.jd
total_exposure = np.floor(
self.exposure.to_value("day") * self.default_exposure_number
self.default_exposure.to_value("day") * self.default_exposure_number
)
single_slew_time = total_exposure + self.default_slew_rate.to_value("day")
Npoints = np.ceil(night_duration / single_slew_time)
Expand Down
37 changes: 21 additions & 16 deletions aware/sql/models.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,25 @@
from __future__ import annotations

from typing import Any
import warnings

import sqlcipher3
from sqlalchemy import (
BLOB,
REAL,
VARCHAR,
Column,
DateTime,
Dialect,
ForeignKey,
Integer,
MetaData,
String,
Text,
BigInteger,
VARCHAR
)
from sqlalchemy.engine import URL, Engine, create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import (
DeclarativeMeta,
Session,
relationship,
scoped_session,
sessionmaker,
)
from sqlalchemy.orm import DeclarativeBase, Session, relationship, sessionmaker
from sqlalchemy.sql.operators import OperatorType
from sqlalchemy.types import TypeDecorator
import sqlcipher3

from ..config import CfgOption

Expand All @@ -42,27 +35,39 @@
query_db = CfgOption("query", "", list)


Base: DeclarativeMeta = declarative_base()
naming_convention = {
"ix": "ix_%(column_0_label)s",
"uq": "uq_%(table_name)s_%(column_0_name)s",
"ck": "ck_%(table_name)s_%(column_0_name)s",
"fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
"pk": "pk_%(table_name)s",
}
metadata = MetaData(naming_convention=naming_convention)


class Base(DeclarativeBase):
metadata = metadata


class TelegramID(TypeDecorator):
"""
Telegram ID, which is stored as a string in the database, but is returned as a
Telegram ID, which is stored as a string in the database, but is returned as a
integer in Python.
"""

impl = VARCHAR
cache_ok = True

def process_bind_param(self, value: Any | None, dialect: Dialect) -> Any:
if value is not None:
value = str(value)
return value

def process_result_value(self, value: Any | None, dialect: Dialect) -> Any | None:
if value is not None:
value = int(value)
return value

def coerce_compared_value(self, op: OperatorType | None, value: Any) -> Any:
return self.impl.coerce_compared_value(op, value)

Expand Down
3 changes: 1 addition & 2 deletions aware/util.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations
import posixpath
from .data import cache_dir
from uuid import uuid4
from .logger import log
import requests
Expand All @@ -9,7 +8,7 @@
def download_file(
url: str,
timeout: float = 1.0,
path: str = cache_dir.value,
path: str = ".",
chunk_size: int = 2048,
overwrite: bool = False,
raise_file_exist: bool = False
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "AWARE"
version = "0.4.6"
version = "0.4.7"
authors = [{name="Nicolai Pankov", email="colinsergesen@gmail.com"}]
requires-python = ">=3.9,<3.12"
dependencies = [
Expand Down

0 comments on commit abda8ff

Please sign in to comment.