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

Notebook for timing/gap test #133

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
133 changes: 133 additions & 0 deletions docs/source/examples/TimingTest.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "f9a24312-c178-494b-b07f-44908a2b48f4",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"# add path to ioos_qc cloned repo\n",
"os.chdir('/Users/sakshamgupta/ioos_qc')"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "6aa17d9e-518c-426f-97dc-87785cf85295",
"metadata": {},
"outputs": [],
"source": [
"from ioos_qc.qartod import aggregate\n",
"from ioos_qc.streams import XarrayStream\n",
"from ioos_qc.results import collect_results, CollectedResult\n",
"from ioos_qc.config import Config"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "6254078b-a5bc-47a8-a857-e23fcb6de972",
"metadata": {},
"outputs": [],
"source": [
"from netCDF4 import Dataset\n",
"from cftime import num2pydate\n",
"import numpy.ma as ma\n",
"import numpy as np\n",
"import pandas as pd\n",
"import yaml\n",
"import seaborn as sns\n",
"import matplotlib.pyplot as plt\n",
"import xarray as xr\n",
"import warnings\n",
"import netCDF4\n",
"import datetime\n",
"# Suppress all warnings\n",
"warnings.filterwarnings('ignore')"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "7a31a705-b097-4487-9889-7e6d2d45c17b",
"metadata": {},
"outputs": [],
"source": [
"class QartodFlags(object):\n",
" \"\"\"Primary flags for QARTOD.\"\"\"\n",
" GOOD = 1\n",
" UNKNOWN = 2\n",
" SUSPECT = 3\n",
" FAIL = 4\n",
" MISSING = 9\n",
"\n",
"FLAGS = QartodFlags # Default name for all check modules\n",
"NOTEVAL_VALUE = QartodFlags.UNKNOWN"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "79cd7a4e-c48b-4e3b-9de7-777ebf51c716",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"flag_arr [1]\n"
]
}
],
"source": [
"tim_stmp = 1728150208 #1643723400 \n",
"tim_inc = 3600 # set 1 hour time interval as expected time window\n",
"now = datetime.datetime.now()\n",
"now_seconds = now.timestamp()\n",
"\n",
"# Calculating the time difference between the current time and the expected time stamp\n",
"time_diff = now_seconds - tim_stmp\n",
"\n",
"# Initialize the flag array with value (1)\n",
"flag_arr = np.ones(1, dtype='uint8')\n",
"\n",
"# If the time difference is greater than the expected time increment, set flag value 4\n",
"if time_diff > tim_inc:\n",
" flag_arr[0] = QartodFlags.FAIL\n",
"\n",
"print(\"flag_arr\", flag_arr)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f454c06e-4cf1-47ff-803b-60a93addf9b2",
"metadata": {},
"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.11.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}