|
718 | 718 | " return fig, axes[:n_subplots]" |
719 | 719 | ] |
720 | 720 | }, |
| 721 | + { |
| 722 | + "cell_type": "code", |
| 723 | + "execution_count": null, |
| 724 | + "id": "96462574-05d0-4827-9c6e-95494307f316", |
| 725 | + "metadata": {}, |
| 726 | + "outputs": [], |
| 727 | + "source": [ |
| 728 | + "import sys\n", |
| 729 | + "sys.exit()" |
| 730 | + ] |
| 731 | + }, |
721 | 732 | { |
722 | 733 | "cell_type": "code", |
723 | 734 | "execution_count": null, |
|
828 | 839 | "make_gif(tempdir)\n", |
829 | 840 | "display(dimg(data=open(tempdir+'/animation.gif', 'rb').read()))" |
830 | 841 | ] |
831 | | - }, |
832 | | - { |
833 | | - "cell_type": "code", |
834 | | - "execution_count": null, |
835 | | - "id": "8364f14c-5056-413f-b796-ad0dad6e2432", |
836 | | - "metadata": {}, |
837 | | - "outputs": [], |
838 | | - "source": [ |
839 | | - "import sys\n", |
840 | | - "sys.exit()" |
841 | | - ] |
842 | | - }, |
843 | | - { |
844 | | - "cell_type": "code", |
845 | | - "execution_count": null, |
846 | | - "id": "0f78775c-d83d-400d-8d48-1bd9527be028", |
847 | | - "metadata": { |
848 | | - "scrolled": true |
849 | | - }, |
850 | | - "outputs": [], |
851 | | - "source": [ |
852 | | - "primary_header = scihdul[0].header\n", |
853 | | - "wcs_sci = WCS(sci_header)\n", |
854 | | - "cd_sci = wcs_sci.wcs.cd\n", |
855 | | - "theta_rad = np.arctan2(cd_sci[0,1], cd_sci[0,0])\n", |
856 | | - "theta_deg = np.degrees(theta_rad)\n", |
857 | | - "\n", |
858 | | - "print(\"method 1 for rot angle:\", theta_deg) #cd_sci, theta_rad, \n", |
859 | | - "\n", |
860 | | - "# Get the pixel scale matrix\n", |
861 | | - "cd_sci = wcs_sci.pixel_scale_matrix\n", |
862 | | - "# Rotation angle (radians → degrees)\n", |
863 | | - "theta_sci = np.degrees(np.arctan2(cd_sci[0,1], cd_sci[0,0]))\n", |
864 | | - "print(f\"Rotation angle: {theta_sci:.3f} deg\")\n", |
865 | | - "\n", |
866 | | - "print('rotation angle in header: ', primary_header['ROTPA'])\n", |
867 | | - "#print(sci_header['ROTPA'])\n", |
868 | | - "theta_sci = 180 - primary_header['ROTPA']\n", |
869 | | - "\n", |
870 | | - "\n", |
871 | | - "fig = plt.figure(figsize=(6, 6))\n", |
872 | | - "ax = fig.add_subplot(111, projection=wcs_sci)\n", |
873 | | - "ax.imshow(sci_hdu.data, cmap='gray', norm='asinh', origin='lower')\n", |
874 | | - "\n", |
875 | | - "wcs_ref = WCS(ref_header)\n", |
876 | | - "\n", |
877 | | - "# Get the pixel scale matrix\n", |
878 | | - "cd_ref = wcs_ref.pixel_scale_matrix\n", |
879 | | - "# Rotation angle (radians → degrees)\n", |
880 | | - "theta_ref = np.degrees(np.arctan2(cd_ref[0,1], cd_ref[0,0]))\n", |
881 | | - "print(f\"Rotation angle: {theta_ref:.3f} deg\")\n", |
882 | | - "\n", |
883 | | - "# instead of doing the above, grab the header keyword:\n", |
884 | | - "# ROTPA which is 180-theta_ref\n", |
885 | | - "\n", |
886 | | - "fig = plt.figure(figsize=(6, 6))\n", |
887 | | - "ax = fig.add_subplot(111, projection=wcs_ref)\n", |
888 | | - "ax.imshow(ref_hdu.data, cmap='gray', norm='asinh', origin='lower')\n" |
889 | | - ] |
890 | | - }, |
891 | | - { |
892 | | - "cell_type": "markdown", |
893 | | - "id": "7313a3a3-6401-4f43-ac8d-9e1f6970da53", |
894 | | - "metadata": {}, |
895 | | - "source": [ |
896 | | - "### 5.4. Warp the template\n", |
897 | | - "\n", |
898 | | - "The `template_coadd` needs to be warped to match the orientation of the science and difference cutouts. Perform the image warping of the `template_coadd` cutout using the `Warper` from `lsst.afw.math`. The warped reference image is defined as `warped_ref`." |
899 | | - ] |
900 | | - }, |
901 | | - { |
902 | | - "cell_type": "code", |
903 | | - "execution_count": null, |
904 | | - "id": "7663f1d6-9d07-43eb-83c4-ab34244fdf99", |
905 | | - "metadata": {}, |
906 | | - "outputs": [], |
907 | | - "source": [ |
908 | | - "warper_config = WarperConfig()\n", |
909 | | - "warper = Warper.fromConfig(warper_config)\n", |
910 | | - "\n", |
911 | | - "sci_wcs = sci.getWcs()\n", |
912 | | - "sci_bbox = sci.getBBox()\n", |
913 | | - "\n", |
914 | | - "warped_ref = warper.warpExposure(sci_wcs, ref, destBBox=sci_bbox)" |
915 | | - ] |
916 | | - }, |
917 | | - { |
918 | | - "cell_type": "markdown", |
919 | | - "id": "db5865c9-7cd4-4bb2-9bf7-5fb550d4df41", |
920 | | - "metadata": {}, |
921 | | - "source": [ |
922 | | - "### 5.5. Display the cutout triplet\n", |
923 | | - "\n", |
924 | | - "Display the science, reference, and difference cutouts for the SNIa candidate associated with the DiaObject 611255759837069401." |
925 | | - ] |
926 | | - }, |
927 | | - { |
928 | | - "cell_type": "code", |
929 | | - "execution_count": null, |
930 | | - "id": "cecaaa36-ec2d-462c-b2ed-cc2f47100b36", |
931 | | - "metadata": {}, |
932 | | - "outputs": [], |
933 | | - "source": [ |
934 | | - "fig, ax = plt.subplots(1, 3, figsize=(8, 3))\n", |
935 | | - "plt.sca(ax[0])\n", |
936 | | - "display1 = afwDisplay.Display(frame=fig)\n", |
937 | | - "display1.scale('linear', 'zscale')\n", |
938 | | - "display1.mtv(sci.image)\n", |
939 | | - "plt.title('science')\n", |
940 | | - "plt.sca(ax[1])\n", |
941 | | - "display2 = afwDisplay.Display(frame=fig)\n", |
942 | | - "display2.scale('linear', 'zscale')\n", |
943 | | - "display2.mtv(warped_ref.image)\n", |
944 | | - "plt.title('template')\n", |
945 | | - "plt.sca(ax[2])\n", |
946 | | - "display3 = afwDisplay.Display(frame=fig)\n", |
947 | | - "display3.scale('linear', 'zscale')\n", |
948 | | - "display3.mtv(diff.image)\n", |
949 | | - "ax[0].set_axis_off()\n", |
950 | | - "ax[1].set_axis_off()\n", |
951 | | - "ax[2].set_axis_off()\n", |
952 | | - "plt.title('difference')\n", |
953 | | - "plt.tight_layout()\n", |
954 | | - "fig.suptitle('DiaObject 611255759837069401, MJD='+str(np.round(scitab['t_max'][0], 2)))\n", |
955 | | - "plt.show()" |
956 | | - ] |
957 | | - }, |
958 | | - { |
959 | | - "cell_type": "markdown", |
960 | | - "id": "6f6f513b-cb08-47ba-b8aa-ea18d18fa320", |
961 | | - "metadata": {}, |
962 | | - "source": [] |
963 | 842 | } |
964 | 843 | ], |
965 | 844 | "metadata": { |
|
0 commit comments