{ "cells": [ { "cell_type": "markdown", "id": "meaning-piano", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "# Temporal" ] }, { "cell_type": "code", "execution_count": 2, "id": "unusual-garbage", "metadata": { "execution": { "iopub.execute_input": "2022-09-15T05:11:33.452638Z", "iopub.status.busy": "2022-09-15T05:11:33.452376Z", "iopub.status.idle": "2022-09-15T05:11:34.763232Z", "shell.execute_reply": "2022-09-15T05:11:34.762626Z" }, "pycharm": { "name": "#%%\n" }, "ExecuteTime": { "end_time": "2023-05-10T23:25:34.814906483Z", "start_time": "2023-05-10T23:25:34.389514725Z" } }, "outputs": [], "source": [ "import starepandas\n", "import pystare\n", "import pandas\n", "import astropy.time\n", "import datetime" ] }, { "cell_type": "code", "execution_count": 11, "id": "eleven-colon", "metadata": { "execution": { "iopub.execute_input": "2022-09-15T05:11:34.766060Z", "iopub.status.busy": "2022-09-15T05:11:34.765794Z", "iopub.status.idle": "2022-09-15T05:11:34.780649Z", "shell.execute_reply": "2022-09-15T05:11:34.780129Z" }, "pycharm": { "name": "#%%\n" } }, "outputs": [ { "data": { "text/plain": " dates\n0 2021-09-03 00:00:00\n1 2021-07-17 11:16:00", "text/html": "
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
dates
02021-09-03 00:00:00
12021-07-17 11:16:00
\n
" }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dates = ['2021-09-03', '2021-07-17 11:16']\n", "dates = pandas.to_datetime(dates, format='ISO8601')\n", "df = starepandas.STAREDataFrame({'dates': dates})\n", "df" ] }, { "cell_type": "code", "execution_count": 12, "id": "separated-setting", "metadata": { "execution": { "iopub.execute_input": "2022-09-15T05:11:34.783289Z", "iopub.status.busy": "2022-09-15T05:11:34.783049Z", "iopub.status.idle": "2022-09-15T05:11:34.786641Z", "shell.execute_reply": "2022-09-15T05:11:34.786016Z" }, "pycharm": { "name": "#%%\n" }, "ExecuteTime": { "end_time": "2023-05-10T23:33:31.268876405Z", "start_time": "2023-05-10T23:33:30.864255485Z" } }, "outputs": [], "source": [ "series = df['dates']" ] }, { "cell_type": "code", "execution_count": 13, "id": "light-placement", "metadata": { "execution": { "iopub.execute_input": "2022-09-15T05:11:34.788773Z", "iopub.status.busy": "2022-09-15T05:11:34.788512Z", "iopub.status.idle": "2022-09-15T05:11:34.793567Z", "shell.execute_reply": "2022-09-15T05:11:34.792950Z" }, "pycharm": { "name": "#%%\n" }, "ExecuteTime": { "end_time": "2023-05-10T23:33:32.349696111Z", "start_time": "2023-05-10T23:33:32.046601552Z" } }, "outputs": [ { "data": { "text/plain": "array([2459460., 2459413.])" }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "times = astropy.time.Time(series, \n", " scale='utc', \n", " format='datetime64')\n", "times.jd1" ] }, { "cell_type": "code", "execution_count": 14, "id": "secure-newfoundland", "metadata": { "execution": { "iopub.execute_input": "2022-09-15T05:11:34.795724Z", "iopub.status.busy": "2022-09-15T05:11:34.795422Z", "iopub.status.idle": "2022-09-15T05:11:34.799115Z", "shell.execute_reply": "2022-09-15T05:11:34.798666Z" }, "pycharm": { "name": "#%%\n" }, "ExecuteTime": { "end_time": "2023-05-10T23:33:35.325728073Z", "start_time": "2023-05-10T23:33:34.331244243Z" } }, "outputs": [], "source": [ "tivs = starepandas.tivs_from_timeseries(df['dates'])" ] }, { "cell_type": "code", "execution_count": 15, "id": "talented-container", "metadata": { "execution": { "iopub.execute_input": "2022-09-15T05:11:34.801396Z", "iopub.status.busy": "2022-09-15T05:11:34.801184Z", "iopub.status.idle": "2022-09-15T05:11:34.803557Z", "shell.execute_reply": "2022-09-15T05:11:34.803156Z" }, "pycharm": { "name": "#%%\n" }, "ExecuteTime": { "end_time": "2023-05-10T23:33:37.656814090Z", "start_time": "2023-05-10T23:33:37.435874192Z" } }, "outputs": [], "source": [ "# Pystare" ] }, { "cell_type": "code", "execution_count": 16, "id": "dental-belly", "metadata": { "execution": { "iopub.execute_input": "2022-09-15T05:11:34.805379Z", "iopub.status.busy": "2022-09-15T05:11:34.805191Z", "iopub.status.idle": "2022-09-15T05:11:34.809922Z", "shell.execute_reply": "2022-09-15T05:11:34.809501Z" }, "pycharm": { "name": "#%%\n" }, "ExecuteTime": { "end_time": "2023-05-10T23:33:38.318607613Z", "start_time": "2023-05-10T23:33:38.161735880Z" } }, "outputs": [ { "data": { "text/plain": "array([2276059438861267137, 2275939265676325057])" }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "times = ['2021-09-03', '2021-07-17 11:16']\n", "times = astropy.time.Time(series, scale='utc', format='datetime64')\n", "tivs = pystare.from_julian_date(times.jd1, times.jd2, scale='utc', forward_res=48, reverse_res=48)\n", "tivs" ] }, { "cell_type": "code", "execution_count": 17, "id": "fixed-import", "metadata": { "execution": { "iopub.execute_input": "2022-09-15T05:11:34.811931Z", "iopub.status.busy": "2022-09-15T05:11:34.811632Z", "iopub.status.idle": "2022-09-15T05:11:34.816935Z", "shell.execute_reply": "2022-09-15T05:11:34.816450Z" }, "pycharm": { "name": "#%%\n" }, "ExecuteTime": { "end_time": "2023-05-10T23:33:40.213085970Z", "start_time": "2023-05-10T23:33:39.826670851Z" } }, "outputs": [ { "data": { "text/plain": "['2021-09-03T00:00:00', '2021-07-17T11:16:00']" }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mss = pystare.to_ms_since_epoch_utc(tivs)\n", "dts = [datetime.datetime.utcfromtimestamp(ms/1000) for ms in mss]\n", "[dt.isoformat() for dt in dts]" ] }, { "cell_type": "code", "execution_count": 18, "id": "disabled-theta", "metadata": { "execution": { "iopub.execute_input": "2022-09-15T05:11:34.818899Z", "iopub.status.busy": "2022-09-15T05:11:34.818683Z", "iopub.status.idle": "2022-09-15T05:11:34.822820Z", "shell.execute_reply": "2022-09-15T05:11:34.822459Z" }, "pycharm": { "name": "#%%\n" }, "ExecuteTime": { "end_time": "2023-05-10T23:33:42.140254214Z", "start_time": "2023-05-10T23:33:41.491963920Z" } }, "outputs": [ { "data": { "text/plain": "array([datetime.datetime(2021, 9, 3, 0, 0),\n datetime.datetime(2021, 7, 17, 11, 16)], dtype=object)" }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "jd = pystare.to_julian_date(tivs, scale='utc')\n", "times = astropy.time.Time(val=jd[0], val2=jd[1], format='jd')\n", "times.to_datetime()" ] }, { "cell_type": "code", "execution_count": null, "id": "diagnostic-hazard", "metadata": { "pycharm": { "name": "#%%\n" } }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.4" } }, "nbformat": 4, "nbformat_minor": 5 }