{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import hyrax\n",
    "\n",
    "# We could be all fancy and use a toml file writer here, but\n",
    "# I'm trying to show how simple this can be.\n",
    "hyrax_config = \"hyrax_config.toml\"\n",
    "with open(hyrax_config, \"w\") as f:\n",
    "    # This simply contains defaults, but you'll have to change at least\n",
    "    # username, password, fits_file, and cutout_dir to your liking\n",
    "    # if you want this to work.\n",
    "\n",
    "    f.write(\n",
    "        \"\"\"\n",
    "\n",
    "    [download]\n",
    "    sw = \"22asec\"\n",
    "    sh = \"22asec\"\n",
    "    filter = [\"HSC-G\", \"HSC-R\", \"HSC-I\", \"HSC-Z\", \"HSC-Y\"]\n",
    "    type = \"coadd\"\n",
    "    rerun = \"pdr3_wide\"\n",
    "\n",
    "    username = \"<Your HSC Username>@local\"\n",
    "    password = \"<Your HSC password>\"\n",
    "\n",
    "    fits_file = \"<Your fits catalog filename goes here>\"\n",
    "    cutout_dir = \"<The file with the cutouts goes here>\"\n",
    "\n",
    "    offset = 0\n",
    "    num_sources = 10\n",
    "            \n",
    "    \"\"\"\n",
    "    )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import hyrax\n",
    "import os\n",
    "from pathlib import Path\n",
    "\n",
    "# os.chdir(Path(hyrax.__file__).parent/\"..\"/\"..\")\n",
    "hyrax_instance = hyrax.Hyrax(config_file=\"hyrax_config.toml\")\n",
    "\n",
    "hyrax_instance.download()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "\n",
    "widths, heights = hyrax_instance.raw_data_dimensions()\n",
    "\n",
    "fig, axs = plt.subplots(1, 2)\n",
    "fig.set_figwidth(12)\n",
    "\n",
    "_, _, _ = axs[0].hist(heights, range=(260, 270), bins=10)\n",
    "_, _, _ = axs[1].hist(widths, range=(260, 270), bins=10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "fibad",
   "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.14"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
