<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://wiki.aob.rs/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ana.Lalovic</id>
	<title>AOB Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.aob.rs/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ana.Lalovic"/>
	<link rel="alternate" type="text/html" href="http://wiki.aob.rs/Special:Contributions/Ana.Lalovic"/>
	<updated>2026-04-04T04:03:24Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.33.1</generator>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=SextractorInstallation&amp;diff=136</id>
		<title>SextractorInstallation</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=SextractorInstallation&amp;diff=136"/>
		<updated>2024-09-11T13:04:43Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* SEXTRACTOR for Ubuntu 24.04 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== SEXTRACTOR for Ubuntu 24.04 ==&lt;br /&gt;
 &lt;br /&gt;
 sudo apt install libatlas-base-dev libblas-dev liblapack-dev&lt;br /&gt;
 &lt;br /&gt;
 wget https://github.com/astromatic/sextractor/archive/refs/tags/2.25.0.tar.gz .&lt;br /&gt;
 tar zxvf 2.25.0.tar.gz&lt;br /&gt;
 cd sextractor-2.25.0/&lt;br /&gt;
 sh autogen.sh&lt;br /&gt;
 ./configure -latlas -lblas&lt;br /&gt;
 sudo make&lt;br /&gt;
 sudo make install&lt;br /&gt;
&lt;br /&gt;
 # Executable: /usr/bin/source-extractor&lt;br /&gt;
 # Additional files: /usr/share/source-extractor/&lt;br /&gt;
&lt;br /&gt;
--------- BELOW THIS LINE -&amp;gt; OLD AND OBSOLETE --------- &lt;br /&gt;
&lt;br /&gt;
This installation manual may be found at:[http://ubuntuforums.org/showthread.php?p=8504839#post8504839 Ubuntu forums]. Just in case it is copied here and slightly modified. Installation of PSFEX is added. It will work under Ubuntu 8.04 32-bit.&lt;br /&gt;
&lt;br /&gt;
== SEXTRACTOR part I ==&lt;br /&gt;
&lt;br /&gt;
* SExtractor &lt;br /&gt;
Download sextractor-2.8.6.tar.gz from http://astromatic.iap.fr/software/sextractor&lt;br /&gt;
 tar zxvf sextractor-2.8.6.tar.gz&lt;br /&gt;
 cd sextractor-2.8.6/&lt;br /&gt;
&lt;br /&gt;
== FFTW ==&lt;br /&gt;
&lt;br /&gt;
* FFTW &lt;br /&gt;
Download fftw-3.2.2.tar.gz from http://www.fftw.org/download.html via http&lt;br /&gt;
 cd sextractor-2.8.6/&lt;br /&gt;
 wget http://www.fftw.org/fftw-3.2.2.tar.gz . &lt;br /&gt;
 tar zxvf fftw-3.2.2.tar.gz&lt;br /&gt;
 cd fftw/&lt;br /&gt;
 ./configure --enable-threads&lt;br /&gt;
 # If compiler problems reported - do &amp;lt;font color=&amp;quot;darkred&amp;quot;&amp;gt;sudo synaptic&amp;lt;/font&amp;gt; and find and install &amp;lt;font color=&amp;quot;darkred&amp;quot;&amp;gt;gfortran&amp;lt;/font&amp;gt; and then do &amp;lt;font color=&amp;quot;darkred&amp;quot;&amp;gt;./configure --enable-threads&amp;lt;/font&amp;gt; again &lt;br /&gt;
 make&lt;br /&gt;
 sudo make install&lt;br /&gt;
&lt;br /&gt;
== CLAPACK ==&lt;br /&gt;
&lt;br /&gt;
* CLAPACK &lt;br /&gt;
Download clapack.tgz from http://www.netlib.org/clapack/clapack.tgz&lt;br /&gt;
 cd /home/[user]/&lt;br /&gt;
 wget http://www.netlib.org/clapack/clapack.tgz .&lt;br /&gt;
 gunzip -c clapack.tgz | tar xvf -&lt;br /&gt;
 cd CLAPACK-3.2.1/&lt;br /&gt;
 cp make.inc.example make.inc&lt;br /&gt;
In file: &amp;lt;font color=&amp;quot;darkviolet&amp;quot;&amp;gt;make.inc&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
replace &amp;lt;b&amp;gt;&amp;lt;font color=&amp;quot;darkblue&amp;quot;&amp;gt;F2CLIB       = ../../F2CLIBS/libf2c.a&amp;lt;/font&amp;gt;&amp;lt;/b&amp;gt; with &amp;lt;b&amp;gt;F2CLIB       = F2CLIBS/libf2c.a&amp;lt;/b&amp;gt; &amp;lt;i&amp;gt;(in 2 places)&amp;lt;/i&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
In file:  &amp;lt;font color=&amp;quot;darkviolet&amp;quot;&amp;gt;CLAPACK-3.2.1/TESTING/LIN/Makefile&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt; replace &amp;lt;b&amp;gt;&amp;lt;font color=&amp;quot;darkblue&amp;quot;&amp;gt;$(F2CLIB)&amp;lt;/font&amp;gt;&amp;lt;/b&amp;gt;  with &amp;lt;b&amp;gt;../../$(F2CLIB)&amp;lt;/b&amp;gt;; replace &amp;lt;b&amp;gt;&amp;lt;font color=&amp;quot;darkblue&amp;quot;&amp;gt;$(BLASLIB)&amp;lt;/font&amp;gt;&amp;lt;/b&amp;gt; with &amp;lt;b&amp;gt;../../BLAS/SRC/$(BLASLIB)&amp;lt;/b&amp;gt;   &amp;lt;br&amp;gt;&lt;br /&gt;
In file:  &amp;lt;font color=&amp;quot;darkviolet&amp;quot;&amp;gt;CLAPACK-3.2.1/TESTING/EIG/Makefile&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt; replace &amp;lt;b&amp;gt;&amp;lt;font color=&amp;quot;darkblue&amp;quot;&amp;gt;$(F2CLIB)&amp;lt;/font&amp;gt;&amp;lt;/b&amp;gt;  with &amp;lt;b&amp;gt;../../$(F2CLIB)&amp;lt;/b&amp;gt;; replace &amp;lt;b&amp;gt;&amp;lt;font color=&amp;quot;darkblue&amp;quot;&amp;gt;$(BLASLIB)&amp;lt;/font&amp;gt;&amp;lt;/b&amp;gt; with &amp;lt;b&amp;gt;../../BLAS/SRC/$(BLASLIB)&amp;lt;/b&amp;gt;   &amp;lt;br&amp;gt;&lt;br /&gt;
In files: &amp;lt;font color=&amp;quot;darkviolet&amp;quot;&amp;gt;CLAPACK-3.2.1/BLAS/TESTING/Makeblat[1-3]&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt; replace &amp;lt;b&amp;gt;&amp;lt;font color=&amp;quot;darkblue&amp;quot;&amp;gt;$(BLASLIB)&amp;lt;/font&amp;gt;&amp;lt;/b&amp;gt; with &amp;lt;b&amp;gt;../SRC/$(BLASLIB)&amp;lt;/b&amp;gt;; replace &amp;lt;b&amp;gt;&amp;lt;font color=&amp;quot;darkblue&amp;quot;&amp;gt;$(F2CLIB)&amp;lt;/font&amp;gt;&amp;lt;/b&amp;gt;  with &amp;lt;b&amp;gt;../../$(F2CLIB)&amp;lt;/b&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;i&amp;gt; sed -i s/&amp;quot;\$(F2CLIB)&amp;quot;/&amp;quot;..\/..\/\$(F2CLIB)&amp;quot;/g Makeblat[1-3]&amp;lt;/i&amp;gt; # Something like this may help&lt;br /&gt;
&lt;br /&gt;
  make f2clib  &amp;lt;small&amp;gt;# If it exits with errors -- fix them (it could be only paths like above) before proceeding&amp;lt;/small&amp;gt;&lt;br /&gt;
  sudo make&lt;br /&gt;
&lt;br /&gt;
== ATLAS ==&lt;br /&gt;
&lt;br /&gt;
* ATLAS &lt;br /&gt;
 sudo apt-get install libblas-doc libblas3gf libblas-dev libblas-test gfortran&lt;br /&gt;
 sudo synaptic (search by lapack and libgsl)&lt;br /&gt;
&lt;br /&gt;
INSTALL: atlas3-base atlas3-doc atlas3-sse2 lapack3 libatlas3gf-sse2  libblas3gf libblas-test libgsl0-dbg libgsl0ldbl liblapack3gf refblas3&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
Download atlas3.8.3.tar.gz from http://sourceforge.net/projects/math-atlas/files/&lt;br /&gt;
 cd /usr/&lt;br /&gt;
 sudo wget http://sourceforge.net/projects/math-atlas/files/Stable/3.8.3/atlas3.8.3.tar.gz/download .&lt;br /&gt;
 sudo zxvf atlas3.8.3.tar.gz &lt;br /&gt;
 cd ATLAS/&lt;br /&gt;
 sudo mkdir linux&lt;br /&gt;
 cd linux&lt;br /&gt;
 sudo /usr/bin/cpufreq-selector -g performance   # not important, skip &lt;br /&gt;
 sudo ../configure -b 32 --with-netlib-lapack=/home/&amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;[user]&amp;lt;/font&amp;gt;/CLAPACK-3.2.1/lapack_LINUX.a # &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt; Put your user name&amp;lt;/font&amp;gt;&lt;br /&gt;
 sudo make build&lt;br /&gt;
 sudo make check&lt;br /&gt;
Successful cmd will list 2 errors that should be ignored (as it says) like this:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
DONE BUILDING TESTERS, RUNNING:&amp;lt;br&amp;gt;&lt;br /&gt;
SCOPING FOR FAILURES IN BIN TESTS:&amp;lt;br&amp;gt;&lt;br /&gt;
fgrep -e fault -e FAULT -e error -e ERROR -e fail -e FAIL \&amp;lt;br&amp;gt;&lt;br /&gt;
	        bin/sanity.out&amp;lt;br&amp;gt;&lt;br /&gt;
8 cases: 8 passed, 0 skipped, 0 failed&amp;lt;br&amp;gt;&lt;br /&gt;
4 cases: 4 passed, 0 skipped, 0 failed&amp;lt;br&amp;gt;&lt;br /&gt;
8 cases: 8 passed, 0 skipped, 0 failed&amp;lt;br&amp;gt;&lt;br /&gt;
4 cases: 4 passed, 0 skipped, 0 failed&amp;lt;br&amp;gt;&lt;br /&gt;
8 cases: 8 passed, 0 skipped, 0 failed&amp;lt;br&amp;gt;&lt;br /&gt;
4 cases: 4 passed, 0 skipped, 0 failed&amp;lt;br&amp;gt;&lt;br /&gt;
8 cases: 8 passed, 0 skipped, 0 failed&amp;lt;br&amp;gt;&lt;br /&gt;
4 cases: 4 passed, 0 skipped, 0 failed&amp;lt;br&amp;gt;&lt;br /&gt;
DONE&amp;lt;br&amp;gt;&lt;br /&gt;
SCOPING FOR FAILURES IN CBLAS TESTS:&amp;lt;br&amp;gt;&lt;br /&gt;
fgrep -e fault -e FAULT -e error -e ERROR -e fail -e FAIL \&amp;lt;br&amp;gt;&lt;br /&gt;
interfaces/blas/C/testing/sanity.out | \&amp;lt;br&amp;gt;&lt;br /&gt;
fgrep -v PASSED&amp;lt;br&amp;gt;&lt;br /&gt;
make[1]: [sanity_test] Error 1 (ignored)&amp;lt;br&amp;gt;&lt;br /&gt;
DONE&amp;lt;br&amp;gt;&lt;br /&gt;
SCOPING FOR FAILURES IN F77BLAS TESTS:&amp;lt;br&amp;gt;&lt;br /&gt;
fgrep -e fault -e FAULT -e error -e ERROR -e fail -e FAIL \&amp;lt;br&amp;gt;&lt;br /&gt;
interfaces/blas/F77/testing/sanity.out | \&amp;lt;br&amp;gt;&lt;br /&gt;
fgrep -v PASSED&amp;lt;br&amp;gt;&lt;br /&gt;
make[1]: [sanity_test] Error 1 (ignored)&amp;lt;br&amp;gt;&lt;br /&gt;
DONE&amp;lt;br&amp;gt;&lt;br /&gt;
make[1]: Leaving directory `/usr/ATLAS/linux'&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 sudo make time&lt;br /&gt;
 sudo make install&lt;br /&gt;
Now the libraries should be at /usr/local/atlas/.&lt;br /&gt;
&lt;br /&gt;
== SEXTRACTOR part II ==&lt;br /&gt;
&lt;br /&gt;
* CONTINUE WITH SEXTRACTOR &lt;br /&gt;
 cd ~/sextractor-2.8.6/&lt;br /&gt;
 ./configure --with-atlas=/usr/local/atlas/lib --with-atlas-incdir=/usr/local/atlas/include&lt;br /&gt;
If an error occures: &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;configure: error: CBLAS/LAPack was compiled without multithreading support! Exiting.&amp;lt;/font&amp;gt;, do&lt;br /&gt;
 sudo ./configure --disable-threads --with-atlas=/usr/local/atlas/lib --with-atlas-incdir=/usr/local/atlas/include&lt;br /&gt;
 # It seems to me that this error occurs if you have a single CPU. With Core Duo processor I haven't experienced any problems.&lt;br /&gt;
And then (in both cases) continue with&lt;br /&gt;
 sudo make&lt;br /&gt;
 sudo make install&lt;br /&gt;
&lt;br /&gt;
This should do the trick. Further, for installation of GIM2D:&amp;lt;br&amp;gt;  &lt;br /&gt;
Download fuzzy.v32.linux.tar.gz from https://www.astrosci.ca/users/GIM2D/installation.html&amp;lt;br&amp;gt;&lt;br /&gt;
Save it in : /iraf/iraf/unix/ &amp;lt;br&amp;gt;&lt;br /&gt;
 tar -xvpf fuzzy.tar&lt;br /&gt;
Add 2 lines to login.cl in your home dir:&amp;lt;br&amp;gt;&lt;br /&gt;
set	fuzzy	= &amp;quot;/iraf/iraf/unix/fuzzy/&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
task $fuzzy.pkg = &amp;quot;fuzzy$fuzzy.cl&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, when you start iraf with goiraf (or whatever you are using) you will see new package fuzzy. Enjoy!&lt;br /&gt;
&lt;br /&gt;
== PSFEX ==&lt;br /&gt;
&lt;br /&gt;
*PSFEX&lt;br /&gt;
&lt;br /&gt;
In addition to sextractor, for installation of [http://astromatic.iap.fr/wsvn/public/listing.php?repname=public+software.psfex&amp;amp;path=%2Ftrunk%2F#path_trunk_  psfex] that makes psfs:&lt;br /&gt;
&lt;br /&gt;
1. Download all .tar.gz files and all stand alone files &amp;lt;i&amp;gt;(The easiest way: check trunk dir and click on the Tarball right and save file)&amp;lt;/i&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
2. Unpack the file: gunzip psfex-trunk.r149.tar.gz | tar xvf - &amp;lt;br&amp;gt;&lt;br /&gt;
3. Change configure to be executable if necessary and the dir name to psfex (if you want)&amp;lt;br&amp;gt;&lt;br /&gt;
4. Enter psfex/ and run&amp;lt;br&amp;gt;&lt;br /&gt;
  sudo ./configure --with-atlas=/usr/local/atlas/lib --with-atlas-incdir=/usr/local/atlas/include&lt;br /&gt;
  # &amp;lt;i&amp;gt;&amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt; If it says sth. like fftw -- single precision not found blah, blah GO BACK to fftw dir and do &amp;lt;/font&amp;gt;&amp;lt;/i&amp;gt;&lt;br /&gt;
   ./configure --enable-threads&lt;br /&gt;
   ./configure --enable-single --enable-threads&lt;br /&gt;
   sudo make&lt;br /&gt;
   sudo make install &lt;br /&gt;
  #&amp;lt;i&amp;gt;And then return to psfex dir and proceed with:&amp;lt;/i&amp;gt;&lt;br /&gt;
  sudo ./configure --disable-threads --with-atlas=/usr/local/atlas/lib --with-atlas-incdir=/usr/local/atlas/include&lt;br /&gt;
5. Run&lt;br /&gt;
  sudo make &lt;br /&gt;
* If it reports a problem in seeing 8 spaces instead of tabs, do&lt;br /&gt;
  sed -i s/&amp;quot;        &amp;quot;/&amp;quot;\t&amp;quot;/g Makefile&lt;br /&gt;
6. continue with&lt;br /&gt;
  sudo make install &lt;br /&gt;
&lt;br /&gt;
Good luck with the rest...&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=SextractorInstallation&amp;diff=135</id>
		<title>SextractorInstallation</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=SextractorInstallation&amp;diff=135"/>
		<updated>2024-09-11T13:03:53Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== SEXTRACTOR for Ubuntu 24.04 ==&lt;br /&gt;
 &lt;br /&gt;
 sudo apt install libatlas-base-dev libblas-dev liblapack-dev&lt;br /&gt;
 &lt;br /&gt;
 wget https://github.com/astromatic/sextractor/archive/refs/tags/2.25.0.tar.gz .&lt;br /&gt;
 tar zxvf 2.25.0.tar.gz&lt;br /&gt;
 cd sextractor-2.25.0/&lt;br /&gt;
 sh autogen.sh&lt;br /&gt;
 ./configure -latlas -lblas&lt;br /&gt;
 sudo make&lt;br /&gt;
 sudo make install&lt;br /&gt;
&lt;br /&gt;
 # Executable: /usr/bin/source-extractor&lt;br /&gt;
 # Additional files: /usr/share/source-extractor/&lt;br /&gt;
&lt;br /&gt;
--------- BELOW THIS LINE ---------&lt;br /&gt;
-------- OLD AND OBSOLETE --------- &lt;br /&gt;
&lt;br /&gt;
This installation manual may be found at:[http://ubuntuforums.org/showthread.php?p=8504839#post8504839 Ubuntu forums]. Just in case it is copied here and slightly modified. Installation of PSFEX is added. It will work under Ubuntu 8.04 32-bit.&lt;br /&gt;
&lt;br /&gt;
== SEXTRACTOR part I ==&lt;br /&gt;
&lt;br /&gt;
* SExtractor &lt;br /&gt;
Download sextractor-2.8.6.tar.gz from http://astromatic.iap.fr/software/sextractor&lt;br /&gt;
 tar zxvf sextractor-2.8.6.tar.gz&lt;br /&gt;
 cd sextractor-2.8.6/&lt;br /&gt;
&lt;br /&gt;
== FFTW ==&lt;br /&gt;
&lt;br /&gt;
* FFTW &lt;br /&gt;
Download fftw-3.2.2.tar.gz from http://www.fftw.org/download.html via http&lt;br /&gt;
 cd sextractor-2.8.6/&lt;br /&gt;
 wget http://www.fftw.org/fftw-3.2.2.tar.gz . &lt;br /&gt;
 tar zxvf fftw-3.2.2.tar.gz&lt;br /&gt;
 cd fftw/&lt;br /&gt;
 ./configure --enable-threads&lt;br /&gt;
 # If compiler problems reported - do &amp;lt;font color=&amp;quot;darkred&amp;quot;&amp;gt;sudo synaptic&amp;lt;/font&amp;gt; and find and install &amp;lt;font color=&amp;quot;darkred&amp;quot;&amp;gt;gfortran&amp;lt;/font&amp;gt; and then do &amp;lt;font color=&amp;quot;darkred&amp;quot;&amp;gt;./configure --enable-threads&amp;lt;/font&amp;gt; again &lt;br /&gt;
 make&lt;br /&gt;
 sudo make install&lt;br /&gt;
&lt;br /&gt;
== CLAPACK ==&lt;br /&gt;
&lt;br /&gt;
* CLAPACK &lt;br /&gt;
Download clapack.tgz from http://www.netlib.org/clapack/clapack.tgz&lt;br /&gt;
 cd /home/[user]/&lt;br /&gt;
 wget http://www.netlib.org/clapack/clapack.tgz .&lt;br /&gt;
 gunzip -c clapack.tgz | tar xvf -&lt;br /&gt;
 cd CLAPACK-3.2.1/&lt;br /&gt;
 cp make.inc.example make.inc&lt;br /&gt;
In file: &amp;lt;font color=&amp;quot;darkviolet&amp;quot;&amp;gt;make.inc&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
replace &amp;lt;b&amp;gt;&amp;lt;font color=&amp;quot;darkblue&amp;quot;&amp;gt;F2CLIB       = ../../F2CLIBS/libf2c.a&amp;lt;/font&amp;gt;&amp;lt;/b&amp;gt; with &amp;lt;b&amp;gt;F2CLIB       = F2CLIBS/libf2c.a&amp;lt;/b&amp;gt; &amp;lt;i&amp;gt;(in 2 places)&amp;lt;/i&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
In file:  &amp;lt;font color=&amp;quot;darkviolet&amp;quot;&amp;gt;CLAPACK-3.2.1/TESTING/LIN/Makefile&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt; replace &amp;lt;b&amp;gt;&amp;lt;font color=&amp;quot;darkblue&amp;quot;&amp;gt;$(F2CLIB)&amp;lt;/font&amp;gt;&amp;lt;/b&amp;gt;  with &amp;lt;b&amp;gt;../../$(F2CLIB)&amp;lt;/b&amp;gt;; replace &amp;lt;b&amp;gt;&amp;lt;font color=&amp;quot;darkblue&amp;quot;&amp;gt;$(BLASLIB)&amp;lt;/font&amp;gt;&amp;lt;/b&amp;gt; with &amp;lt;b&amp;gt;../../BLAS/SRC/$(BLASLIB)&amp;lt;/b&amp;gt;   &amp;lt;br&amp;gt;&lt;br /&gt;
In file:  &amp;lt;font color=&amp;quot;darkviolet&amp;quot;&amp;gt;CLAPACK-3.2.1/TESTING/EIG/Makefile&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt; replace &amp;lt;b&amp;gt;&amp;lt;font color=&amp;quot;darkblue&amp;quot;&amp;gt;$(F2CLIB)&amp;lt;/font&amp;gt;&amp;lt;/b&amp;gt;  with &amp;lt;b&amp;gt;../../$(F2CLIB)&amp;lt;/b&amp;gt;; replace &amp;lt;b&amp;gt;&amp;lt;font color=&amp;quot;darkblue&amp;quot;&amp;gt;$(BLASLIB)&amp;lt;/font&amp;gt;&amp;lt;/b&amp;gt; with &amp;lt;b&amp;gt;../../BLAS/SRC/$(BLASLIB)&amp;lt;/b&amp;gt;   &amp;lt;br&amp;gt;&lt;br /&gt;
In files: &amp;lt;font color=&amp;quot;darkviolet&amp;quot;&amp;gt;CLAPACK-3.2.1/BLAS/TESTING/Makeblat[1-3]&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt; replace &amp;lt;b&amp;gt;&amp;lt;font color=&amp;quot;darkblue&amp;quot;&amp;gt;$(BLASLIB)&amp;lt;/font&amp;gt;&amp;lt;/b&amp;gt; with &amp;lt;b&amp;gt;../SRC/$(BLASLIB)&amp;lt;/b&amp;gt;; replace &amp;lt;b&amp;gt;&amp;lt;font color=&amp;quot;darkblue&amp;quot;&amp;gt;$(F2CLIB)&amp;lt;/font&amp;gt;&amp;lt;/b&amp;gt;  with &amp;lt;b&amp;gt;../../$(F2CLIB)&amp;lt;/b&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;i&amp;gt; sed -i s/&amp;quot;\$(F2CLIB)&amp;quot;/&amp;quot;..\/..\/\$(F2CLIB)&amp;quot;/g Makeblat[1-3]&amp;lt;/i&amp;gt; # Something like this may help&lt;br /&gt;
&lt;br /&gt;
  make f2clib  &amp;lt;small&amp;gt;# If it exits with errors -- fix them (it could be only paths like above) before proceeding&amp;lt;/small&amp;gt;&lt;br /&gt;
  sudo make&lt;br /&gt;
&lt;br /&gt;
== ATLAS ==&lt;br /&gt;
&lt;br /&gt;
* ATLAS &lt;br /&gt;
 sudo apt-get install libblas-doc libblas3gf libblas-dev libblas-test gfortran&lt;br /&gt;
 sudo synaptic (search by lapack and libgsl)&lt;br /&gt;
&lt;br /&gt;
INSTALL: atlas3-base atlas3-doc atlas3-sse2 lapack3 libatlas3gf-sse2  libblas3gf libblas-test libgsl0-dbg libgsl0ldbl liblapack3gf refblas3&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
Download atlas3.8.3.tar.gz from http://sourceforge.net/projects/math-atlas/files/&lt;br /&gt;
 cd /usr/&lt;br /&gt;
 sudo wget http://sourceforge.net/projects/math-atlas/files/Stable/3.8.3/atlas3.8.3.tar.gz/download .&lt;br /&gt;
 sudo zxvf atlas3.8.3.tar.gz &lt;br /&gt;
 cd ATLAS/&lt;br /&gt;
 sudo mkdir linux&lt;br /&gt;
 cd linux&lt;br /&gt;
 sudo /usr/bin/cpufreq-selector -g performance   # not important, skip &lt;br /&gt;
 sudo ../configure -b 32 --with-netlib-lapack=/home/&amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;[user]&amp;lt;/font&amp;gt;/CLAPACK-3.2.1/lapack_LINUX.a # &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt; Put your user name&amp;lt;/font&amp;gt;&lt;br /&gt;
 sudo make build&lt;br /&gt;
 sudo make check&lt;br /&gt;
Successful cmd will list 2 errors that should be ignored (as it says) like this:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
DONE BUILDING TESTERS, RUNNING:&amp;lt;br&amp;gt;&lt;br /&gt;
SCOPING FOR FAILURES IN BIN TESTS:&amp;lt;br&amp;gt;&lt;br /&gt;
fgrep -e fault -e FAULT -e error -e ERROR -e fail -e FAIL \&amp;lt;br&amp;gt;&lt;br /&gt;
	        bin/sanity.out&amp;lt;br&amp;gt;&lt;br /&gt;
8 cases: 8 passed, 0 skipped, 0 failed&amp;lt;br&amp;gt;&lt;br /&gt;
4 cases: 4 passed, 0 skipped, 0 failed&amp;lt;br&amp;gt;&lt;br /&gt;
8 cases: 8 passed, 0 skipped, 0 failed&amp;lt;br&amp;gt;&lt;br /&gt;
4 cases: 4 passed, 0 skipped, 0 failed&amp;lt;br&amp;gt;&lt;br /&gt;
8 cases: 8 passed, 0 skipped, 0 failed&amp;lt;br&amp;gt;&lt;br /&gt;
4 cases: 4 passed, 0 skipped, 0 failed&amp;lt;br&amp;gt;&lt;br /&gt;
8 cases: 8 passed, 0 skipped, 0 failed&amp;lt;br&amp;gt;&lt;br /&gt;
4 cases: 4 passed, 0 skipped, 0 failed&amp;lt;br&amp;gt;&lt;br /&gt;
DONE&amp;lt;br&amp;gt;&lt;br /&gt;
SCOPING FOR FAILURES IN CBLAS TESTS:&amp;lt;br&amp;gt;&lt;br /&gt;
fgrep -e fault -e FAULT -e error -e ERROR -e fail -e FAIL \&amp;lt;br&amp;gt;&lt;br /&gt;
interfaces/blas/C/testing/sanity.out | \&amp;lt;br&amp;gt;&lt;br /&gt;
fgrep -v PASSED&amp;lt;br&amp;gt;&lt;br /&gt;
make[1]: [sanity_test] Error 1 (ignored)&amp;lt;br&amp;gt;&lt;br /&gt;
DONE&amp;lt;br&amp;gt;&lt;br /&gt;
SCOPING FOR FAILURES IN F77BLAS TESTS:&amp;lt;br&amp;gt;&lt;br /&gt;
fgrep -e fault -e FAULT -e error -e ERROR -e fail -e FAIL \&amp;lt;br&amp;gt;&lt;br /&gt;
interfaces/blas/F77/testing/sanity.out | \&amp;lt;br&amp;gt;&lt;br /&gt;
fgrep -v PASSED&amp;lt;br&amp;gt;&lt;br /&gt;
make[1]: [sanity_test] Error 1 (ignored)&amp;lt;br&amp;gt;&lt;br /&gt;
DONE&amp;lt;br&amp;gt;&lt;br /&gt;
make[1]: Leaving directory `/usr/ATLAS/linux'&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 sudo make time&lt;br /&gt;
 sudo make install&lt;br /&gt;
Now the libraries should be at /usr/local/atlas/.&lt;br /&gt;
&lt;br /&gt;
== SEXTRACTOR part II ==&lt;br /&gt;
&lt;br /&gt;
* CONTINUE WITH SEXTRACTOR &lt;br /&gt;
 cd ~/sextractor-2.8.6/&lt;br /&gt;
 ./configure --with-atlas=/usr/local/atlas/lib --with-atlas-incdir=/usr/local/atlas/include&lt;br /&gt;
If an error occures: &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;configure: error: CBLAS/LAPack was compiled without multithreading support! Exiting.&amp;lt;/font&amp;gt;, do&lt;br /&gt;
 sudo ./configure --disable-threads --with-atlas=/usr/local/atlas/lib --with-atlas-incdir=/usr/local/atlas/include&lt;br /&gt;
 # It seems to me that this error occurs if you have a single CPU. With Core Duo processor I haven't experienced any problems.&lt;br /&gt;
And then (in both cases) continue with&lt;br /&gt;
 sudo make&lt;br /&gt;
 sudo make install&lt;br /&gt;
&lt;br /&gt;
This should do the trick. Further, for installation of GIM2D:&amp;lt;br&amp;gt;  &lt;br /&gt;
Download fuzzy.v32.linux.tar.gz from https://www.astrosci.ca/users/GIM2D/installation.html&amp;lt;br&amp;gt;&lt;br /&gt;
Save it in : /iraf/iraf/unix/ &amp;lt;br&amp;gt;&lt;br /&gt;
 tar -xvpf fuzzy.tar&lt;br /&gt;
Add 2 lines to login.cl in your home dir:&amp;lt;br&amp;gt;&lt;br /&gt;
set	fuzzy	= &amp;quot;/iraf/iraf/unix/fuzzy/&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
task $fuzzy.pkg = &amp;quot;fuzzy$fuzzy.cl&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, when you start iraf with goiraf (or whatever you are using) you will see new package fuzzy. Enjoy!&lt;br /&gt;
&lt;br /&gt;
== PSFEX ==&lt;br /&gt;
&lt;br /&gt;
*PSFEX&lt;br /&gt;
&lt;br /&gt;
In addition to sextractor, for installation of [http://astromatic.iap.fr/wsvn/public/listing.php?repname=public+software.psfex&amp;amp;path=%2Ftrunk%2F#path_trunk_  psfex] that makes psfs:&lt;br /&gt;
&lt;br /&gt;
1. Download all .tar.gz files and all stand alone files &amp;lt;i&amp;gt;(The easiest way: check trunk dir and click on the Tarball right and save file)&amp;lt;/i&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
2. Unpack the file: gunzip psfex-trunk.r149.tar.gz | tar xvf - &amp;lt;br&amp;gt;&lt;br /&gt;
3. Change configure to be executable if necessary and the dir name to psfex (if you want)&amp;lt;br&amp;gt;&lt;br /&gt;
4. Enter psfex/ and run&amp;lt;br&amp;gt;&lt;br /&gt;
  sudo ./configure --with-atlas=/usr/local/atlas/lib --with-atlas-incdir=/usr/local/atlas/include&lt;br /&gt;
  # &amp;lt;i&amp;gt;&amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt; If it says sth. like fftw -- single precision not found blah, blah GO BACK to fftw dir and do &amp;lt;/font&amp;gt;&amp;lt;/i&amp;gt;&lt;br /&gt;
   ./configure --enable-threads&lt;br /&gt;
   ./configure --enable-single --enable-threads&lt;br /&gt;
   sudo make&lt;br /&gt;
   sudo make install &lt;br /&gt;
  #&amp;lt;i&amp;gt;And then return to psfex dir and proceed with:&amp;lt;/i&amp;gt;&lt;br /&gt;
  sudo ./configure --disable-threads --with-atlas=/usr/local/atlas/lib --with-atlas-incdir=/usr/local/atlas/include&lt;br /&gt;
5. Run&lt;br /&gt;
  sudo make &lt;br /&gt;
* If it reports a problem in seeing 8 spaces instead of tabs, do&lt;br /&gt;
  sed -i s/&amp;quot;        &amp;quot;/&amp;quot;\t&amp;quot;/g Makefile&lt;br /&gt;
6. continue with&lt;br /&gt;
  sudo make install &lt;br /&gt;
&lt;br /&gt;
Good luck with the rest...&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=134</id>
		<title>CCD data reduction</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=134"/>
		<updated>2024-01-03T20:28:18Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* Astrometry */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic data reduction using IRAF ==&lt;br /&gt;
&lt;br /&gt;
Below is a bash script that creates lists of all images: biases, flats, darks and targets.&lt;br /&gt;
Special case of dark frames of 600sec that Milankovic generates is used&lt;br /&gt;
Last lines create ascii files with median values in flat frames that will be used&lt;br /&gt;
for their normalization.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;&lt;br /&gt;
The script creates reduce.cl IRAF script that should be run from iraf:&lt;br /&gt;
cl &amp;lt; reduce.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
rm *list&lt;br /&gt;
for frame in $(ls *fit); do&lt;br /&gt;
	filterType=$(gethead filter $frame)&lt;br /&gt;
	imageType=$(gethead imagetyp $frame)&lt;br /&gt;
	outFileName=$(echo $imageType | tr '[:upper:]' '[:lower:]')&lt;br /&gt;
	# test if DARK&lt;br /&gt;
	if [ ${imageType} = &amp;quot;DARK&amp;quot; ]; then&lt;br /&gt;
 		exptime=$(gethead exptime $frame | cut -d. -f1) &lt;br /&gt;
 		ls $frame &amp;gt;&amp;gt; ${outFileName}${exptime}&amp;quot;s&amp;quot;.list &lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${exptime}&amp;quot;s&amp;quot;.list&lt;br /&gt;
	else ls $frame &amp;gt;&amp;gt; ${outFileName}${filterType}.list&lt;br /&gt;
	fi&lt;br /&gt;
	# test if LIGHT and create additional lists&lt;br /&gt;
	if [ ${imageType} = &amp;quot;LIGHT&amp;quot; ]; then&lt;br /&gt;
	 	exptime=$(gethead exptime $frame | cut -d. -f1)&lt;br /&gt;
		echo $exptime &amp;gt;&amp;gt; exptime${filterType}.list&lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bdf&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bdf&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	 else if [ ${imageType} = &amp;quot;FLAT&amp;quot; ]; then&lt;br /&gt;
                echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
                echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;nbd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;nbd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	      fi&lt;br /&gt;
	 fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
# Create dark current corresponding to each light frame using exposure time&lt;br /&gt;
for exptime in $(ls exptime*.list); do &lt;br /&gt;
	filter=$(echo $exptime | sed -e s/exptime//g -e s/\.list//g);&lt;br /&gt;
	awk -v filter=${filter} '{print &amp;quot;dc&amp;quot;NR&amp;quot;_&amp;quot;filter&amp;quot;.fits&amp;quot;}' exptime${filter}.list  &amp;gt; dc${filter}.list&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce.cl ]; then rm reduce.cl; fi&lt;br /&gt;
echo &amp;quot;imdelete master_bias,dc_600s,dc_5s,dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bias.list master_bias comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark600s.list - master_bias @bdark600s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark5s.list - master_bias @bdark5s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark5s.list dc_5s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark600s.list dc_600s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl &lt;br /&gt;
echo &amp;quot;imarith dc_600s / 600 dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
&lt;br /&gt;
for flats in $(ls flat*list); do&lt;br /&gt;
        filterType=$(echo $flats | sed s/flat//g | cut -d. -f1)&lt;br /&gt;
        #echo $filterType&lt;br /&gt;
	echo &amp;quot;imarith @flat${filterType}.list - master_bias @bflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imarith @bflat${filterType}.list - dc_5s @bdflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imstat @bdflat${filterType}.list fields=\&amp;quot;image,midpt\&amp;quot; format- &amp;gt; norm${filterType}.txt&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Flat field normalization ==&lt;br /&gt;
&lt;br /&gt;
From terminal (bash):&lt;br /&gt;
&amp;lt;pre&amp;gt;  &lt;br /&gt;
for norm in $(ls norm*txt); do while read line; do echo $line | awk '! /^#/{print &amp;quot;imarith &amp;quot;$1&amp;quot; / &amp;quot;$2,&amp;quot;n&amp;quot;$1}'; done &amp;lt; $norm ; done &amp;gt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From terminal (IRAF):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cl &amp;lt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Calibration of science frames ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash/&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce_images.cl ]; then rm reduce_images.cl; fi&lt;br /&gt;
&lt;br /&gt;
for flat_list in $(ls nbdflat*list); do&lt;br /&gt;
        filter=$(echo ${flat_list} | sed -e s/nbdflat//g -e s/\.list//g);&lt;br /&gt;
        if [ -e light${filter}.list ]; then&lt;br /&gt;
                echo &amp;quot;imcomb @nbdflat${filter}.list master_flat_${filter} comb=med&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith @light${filter}.list - master_bias @blight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith dc_1s * @exptime${filter}.list @dc${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith @blight${filter}.list - @dc${filter}.list @bdlight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith @bdlight${filter}.list / master_flat_${filter} @bdflight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
        fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This script creates IRAF's script reduce_images.cl that should be started from IRAF's terminal. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;&lt;br /&gt;
AFTER the script is run from IRAF terminal, clean up the junk (from bash terminal):&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat blight*list bdlight*list bflat*list bdflat*list nbdflat*list bdark*list dc*.list &amp;gt; tmp_files.list&lt;br /&gt;
rm $(&amp;lt;tmp_files.list)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  BPM &amp;amp; object mask creation ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cat bpmask.cl&lt;br /&gt;
imstat dc_600s field=&amp;quot;image,mean,stddev&amp;quot; for- &amp;gt; hot.txt&lt;br /&gt;
imstat master_flat_FILTER fields=&amp;quot;image,mean&amp;quot; for- &amp;gt; cold.txt&lt;br /&gt;
cl &amp;lt; bpmask.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;gt; b) ? 1 : 0)\&amp;quot; hot&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;($2+3.*$3)*0.75}' hot.txt &amp;gt; hot.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;lt; b) ? 1 : 0)\&amp;quot; cold&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;$2*0.9}' cold.txt &amp;gt; cold.cl&lt;br /&gt;
cl &amp;lt; hot.cl&lt;br /&gt;
cl &amp;lt; cold.cl&lt;br /&gt;
# cat bpm.cl&lt;br /&gt;
imexpr &amp;quot;max(a,b)&amp;quot; bpmFILTER.pl a=hotFILTER.pl b=coldFILTER.pl&lt;br /&gt;
hedit @bdfFILTER.list BPM bpmFILTER.pl add+ ver- &lt;br /&gt;
# sed 's/FILTER/'${filter}'/g'  bpm.cl &amp;gt; dobpm.cl&lt;br /&gt;
cl &amp;lt; dobpm.cl&lt;br /&gt;
  &lt;br /&gt;
# Object masks creation&lt;br /&gt;
nproto&lt;br /&gt;
objmask @bdfFILTER.list @objbdfFILTER.list masks=&amp;quot;!BPM&amp;quot; hsig=2 lsig=2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Astrometry ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh/&lt;br /&gt;
&lt;br /&gt;
for list in $(ls bdflight*list); do&lt;br /&gt;
	while read frame; do &lt;br /&gt;
	ra=$(gethead OBJCTRA $frame | awk '{print $1&amp;quot;:&amp;quot;$2&amp;quot;:&amp;quot;$3}')&lt;br /&gt;
	dec=$(gethead OBJCTDEC $frame | awk '{print $1&amp;quot;:&amp;quot;$2&amp;quot;:&amp;quot;$3}')&lt;br /&gt;
	solve-field &amp;quot;$frame&amp;quot; --ra &amp;quot;$ra&amp;quot; --dec &amp;quot;$dec&amp;quot; --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcs&amp;quot;$frame&amp;quot; -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy --wcs bla.wcs&lt;br /&gt;
	done &amp;lt; $list&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Clear up the rest of the junk after running the previous script:&lt;br /&gt;
rm norm*txt master_*fits none* bla.wcs dc*fits *.list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Supersky flat ==&lt;br /&gt;
 # Creation of super sky flat, normalization to each individual image median background and final stacking&lt;br /&gt;
 # cat stat.cl&lt;br /&gt;
 real mini&lt;br /&gt;
 real sky&lt;br /&gt;
 imstat(&amp;quot;img&amp;quot;,fields=&amp;quot;min&amp;quot;,lower=INDEF,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, mini)&lt;br /&gt;
 imcalc(input=&amp;quot;img,msk&amp;quot;,output=&amp;quot;skyimage&amp;quot;,equals=&amp;quot;if(im2==0.) then im1 else &amp;quot;//mini-0.001,ver-)&lt;br /&gt;
 imstat(&amp;quot;skyimage&amp;quot;,fields=&amp;quot;midpt&amp;quot;,lower=mini-0.001,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, sky)&lt;br /&gt;
 print(&amp;quot;img&amp;quot;,&amp;quot; &amp;quot;,sky)&lt;br /&gt;
 imarith(&amp;quot;img&amp;quot;,&amp;quot;/&amp;quot;,sky,&amp;quot;norm&amp;quot;)&lt;br /&gt;
 imdelete(&amp;quot;skyimage&amp;quot;,yes)&lt;br /&gt;
 # while read line; do img=$(echo $line | awk '{print $1}'); msk=&amp;quot;obj&amp;quot;${img%.*}.pl; rsky=&amp;quot;norm&amp;quot;${img}; cat stat.cl | sed -e 's/img/'${img}'/g' \&lt;br /&gt;
 -e 's/msk/'${msk}'/g'  -e 's/norm/'${rsky}'/g'; done &amp;lt; bdf${filter}.list &amp;gt;  bla.cl&lt;br /&gt;
 cl &amp;lt; bla.cl &amp;gt; med_values.txt&lt;br /&gt;
 # ls normbdf*fit &amp;gt; norm.list&lt;br /&gt;
 imcomb @norm.list norm.fits comb=med masktype=&amp;quot;!OBJMASK&amp;quot; maskval=0&lt;br /&gt;
 # awk '{print &amp;quot;imarith norm.fits * &amp;quot;$2,&amp;quot; n&amp;quot;$1}' med_values.txt &amp;gt; donorm.cl&lt;br /&gt;
 cl &amp;lt; donorm.cl&lt;br /&gt;
 # awk '{print &amp;quot;imarith&amp;quot;,$1,&amp;quot;-&amp;quot;,&amp;quot;n&amp;quot;$1,&amp;quot;s&amp;quot;$1}' med_values.txt &amp;gt; do.cl&lt;br /&gt;
 cl &amp;lt; do.cl&lt;br /&gt;
    &lt;br /&gt;
 imcomb s@bdfFILTER.list final.fits comb=med offset=&amp;quot;wcs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Surface brightness limit ==&lt;br /&gt;
&lt;br /&gt;
 1. Calibrate the image taking non-saturated stars and not too faint stars: intercept and slope (TOPCAT with SDSS DR12 from Vizier)&lt;br /&gt;
 2. Calculate statistics inside at least 20 (empty, i.e. without objects) boxes of the size of 10&amp;quot; (for example if 1pix=0.396&amp;quot; than 10&amp;quot;~25 pix so boxes = 25 pix &amp;amp;times; 25 pix)&lt;br /&gt;
 3. Take the mean value of the standard deviation inside boxes and it's standard deviation&lt;br /&gt;
 4. Calculate SBmin and SBmax as: &lt;br /&gt;
    SBmax =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;-stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
    SBmin =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;+stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
 where &amp;lt;&amp;amp;sigma;&amp;gt; is the average standard deviation inside boxes and stdev(&amp;lt;&amp;amp;sigma;&amp;gt;) its standard deviation.&lt;br /&gt;
 5. Finally, 1 sigma surface brightness limit (SBlim) is given as:&lt;br /&gt;
    SBlim = (SBmin+SBmax)/2 +/- (SBmax-SBmin)/2&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=133</id>
		<title>CCD data reduction</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=133"/>
		<updated>2024-01-03T20:27:58Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* Astrometry */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic data reduction using IRAF ==&lt;br /&gt;
&lt;br /&gt;
Below is a bash script that creates lists of all images: biases, flats, darks and targets.&lt;br /&gt;
Special case of dark frames of 600sec that Milankovic generates is used&lt;br /&gt;
Last lines create ascii files with median values in flat frames that will be used&lt;br /&gt;
for their normalization.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;&lt;br /&gt;
The script creates reduce.cl IRAF script that should be run from iraf:&lt;br /&gt;
cl &amp;lt; reduce.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
rm *list&lt;br /&gt;
for frame in $(ls *fit); do&lt;br /&gt;
	filterType=$(gethead filter $frame)&lt;br /&gt;
	imageType=$(gethead imagetyp $frame)&lt;br /&gt;
	outFileName=$(echo $imageType | tr '[:upper:]' '[:lower:]')&lt;br /&gt;
	# test if DARK&lt;br /&gt;
	if [ ${imageType} = &amp;quot;DARK&amp;quot; ]; then&lt;br /&gt;
 		exptime=$(gethead exptime $frame | cut -d. -f1) &lt;br /&gt;
 		ls $frame &amp;gt;&amp;gt; ${outFileName}${exptime}&amp;quot;s&amp;quot;.list &lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${exptime}&amp;quot;s&amp;quot;.list&lt;br /&gt;
	else ls $frame &amp;gt;&amp;gt; ${outFileName}${filterType}.list&lt;br /&gt;
	fi&lt;br /&gt;
	# test if LIGHT and create additional lists&lt;br /&gt;
	if [ ${imageType} = &amp;quot;LIGHT&amp;quot; ]; then&lt;br /&gt;
	 	exptime=$(gethead exptime $frame | cut -d. -f1)&lt;br /&gt;
		echo $exptime &amp;gt;&amp;gt; exptime${filterType}.list&lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bdf&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bdf&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	 else if [ ${imageType} = &amp;quot;FLAT&amp;quot; ]; then&lt;br /&gt;
                echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
                echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;nbd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;nbd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	      fi&lt;br /&gt;
	 fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
# Create dark current corresponding to each light frame using exposure time&lt;br /&gt;
for exptime in $(ls exptime*.list); do &lt;br /&gt;
	filter=$(echo $exptime | sed -e s/exptime//g -e s/\.list//g);&lt;br /&gt;
	awk -v filter=${filter} '{print &amp;quot;dc&amp;quot;NR&amp;quot;_&amp;quot;filter&amp;quot;.fits&amp;quot;}' exptime${filter}.list  &amp;gt; dc${filter}.list&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce.cl ]; then rm reduce.cl; fi&lt;br /&gt;
echo &amp;quot;imdelete master_bias,dc_600s,dc_5s,dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bias.list master_bias comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark600s.list - master_bias @bdark600s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark5s.list - master_bias @bdark5s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark5s.list dc_5s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark600s.list dc_600s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl &lt;br /&gt;
echo &amp;quot;imarith dc_600s / 600 dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
&lt;br /&gt;
for flats in $(ls flat*list); do&lt;br /&gt;
        filterType=$(echo $flats | sed s/flat//g | cut -d. -f1)&lt;br /&gt;
        #echo $filterType&lt;br /&gt;
	echo &amp;quot;imarith @flat${filterType}.list - master_bias @bflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imarith @bflat${filterType}.list - dc_5s @bdflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imstat @bdflat${filterType}.list fields=\&amp;quot;image,midpt\&amp;quot; format- &amp;gt; norm${filterType}.txt&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Flat field normalization ==&lt;br /&gt;
&lt;br /&gt;
From terminal (bash):&lt;br /&gt;
&amp;lt;pre&amp;gt;  &lt;br /&gt;
for norm in $(ls norm*txt); do while read line; do echo $line | awk '! /^#/{print &amp;quot;imarith &amp;quot;$1&amp;quot; / &amp;quot;$2,&amp;quot;n&amp;quot;$1}'; done &amp;lt; $norm ; done &amp;gt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From terminal (IRAF):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cl &amp;lt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Calibration of science frames ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash/&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce_images.cl ]; then rm reduce_images.cl; fi&lt;br /&gt;
&lt;br /&gt;
for flat_list in $(ls nbdflat*list); do&lt;br /&gt;
        filter=$(echo ${flat_list} | sed -e s/nbdflat//g -e s/\.list//g);&lt;br /&gt;
        if [ -e light${filter}.list ]; then&lt;br /&gt;
                echo &amp;quot;imcomb @nbdflat${filter}.list master_flat_${filter} comb=med&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith @light${filter}.list - master_bias @blight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith dc_1s * @exptime${filter}.list @dc${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith @blight${filter}.list - @dc${filter}.list @bdlight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith @bdlight${filter}.list / master_flat_${filter} @bdflight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
        fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This script creates IRAF's script reduce_images.cl that should be started from IRAF's terminal. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;&lt;br /&gt;
AFTER the script is run from IRAF terminal, clean up the junk (from bash terminal):&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat blight*list bdlight*list bflat*list bdflat*list nbdflat*list bdark*list dc*.list &amp;gt; tmp_files.list&lt;br /&gt;
rm $(&amp;lt;tmp_files.list)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  BPM &amp;amp; object mask creation ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cat bpmask.cl&lt;br /&gt;
imstat dc_600s field=&amp;quot;image,mean,stddev&amp;quot; for- &amp;gt; hot.txt&lt;br /&gt;
imstat master_flat_FILTER fields=&amp;quot;image,mean&amp;quot; for- &amp;gt; cold.txt&lt;br /&gt;
cl &amp;lt; bpmask.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;gt; b) ? 1 : 0)\&amp;quot; hot&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;($2+3.*$3)*0.75}' hot.txt &amp;gt; hot.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;lt; b) ? 1 : 0)\&amp;quot; cold&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;$2*0.9}' cold.txt &amp;gt; cold.cl&lt;br /&gt;
cl &amp;lt; hot.cl&lt;br /&gt;
cl &amp;lt; cold.cl&lt;br /&gt;
# cat bpm.cl&lt;br /&gt;
imexpr &amp;quot;max(a,b)&amp;quot; bpmFILTER.pl a=hotFILTER.pl b=coldFILTER.pl&lt;br /&gt;
hedit @bdfFILTER.list BPM bpmFILTER.pl add+ ver- &lt;br /&gt;
# sed 's/FILTER/'${filter}'/g'  bpm.cl &amp;gt; dobpm.cl&lt;br /&gt;
cl &amp;lt; dobpm.cl&lt;br /&gt;
  &lt;br /&gt;
# Object masks creation&lt;br /&gt;
nproto&lt;br /&gt;
objmask @bdfFILTER.list @objbdfFILTER.list masks=&amp;quot;!BPM&amp;quot; hsig=2 lsig=2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Astrometry ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh/&lt;br /&gt;
&lt;br /&gt;
for list in $(ls bdflight*list); do&lt;br /&gt;
	while read frame; do &lt;br /&gt;
	ra=$(gethead OBJCTRA $frame | awk '{print $1&amp;quot;:&amp;quot;$2&amp;quot;:&amp;quot;$3}')&lt;br /&gt;
	dec=$(gethead OBJCTDEC $frame | awk '{print $1&amp;quot;:&amp;quot;$2&amp;quot;:&amp;quot;$3}')&lt;br /&gt;
	solve-field &amp;quot;$frame&amp;quot; --ra &amp;quot;$ra&amp;quot; --dec &amp;quot;$dec&amp;quot; --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcs&amp;quot;$frame&amp;quot; -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy --wcs bla.wcs&lt;br /&gt;
	done &amp;lt; $list&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Clear up the rest of the junk after running previous script:&lt;br /&gt;
rm norm*txt master_*fits none* bla.wcs dc*fits *.list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Supersky flat ==&lt;br /&gt;
 # Creation of super sky flat, normalization to each individual image median background and final stacking&lt;br /&gt;
 # cat stat.cl&lt;br /&gt;
 real mini&lt;br /&gt;
 real sky&lt;br /&gt;
 imstat(&amp;quot;img&amp;quot;,fields=&amp;quot;min&amp;quot;,lower=INDEF,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, mini)&lt;br /&gt;
 imcalc(input=&amp;quot;img,msk&amp;quot;,output=&amp;quot;skyimage&amp;quot;,equals=&amp;quot;if(im2==0.) then im1 else &amp;quot;//mini-0.001,ver-)&lt;br /&gt;
 imstat(&amp;quot;skyimage&amp;quot;,fields=&amp;quot;midpt&amp;quot;,lower=mini-0.001,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, sky)&lt;br /&gt;
 print(&amp;quot;img&amp;quot;,&amp;quot; &amp;quot;,sky)&lt;br /&gt;
 imarith(&amp;quot;img&amp;quot;,&amp;quot;/&amp;quot;,sky,&amp;quot;norm&amp;quot;)&lt;br /&gt;
 imdelete(&amp;quot;skyimage&amp;quot;,yes)&lt;br /&gt;
 # while read line; do img=$(echo $line | awk '{print $1}'); msk=&amp;quot;obj&amp;quot;${img%.*}.pl; rsky=&amp;quot;norm&amp;quot;${img}; cat stat.cl | sed -e 's/img/'${img}'/g' \&lt;br /&gt;
 -e 's/msk/'${msk}'/g'  -e 's/norm/'${rsky}'/g'; done &amp;lt; bdf${filter}.list &amp;gt;  bla.cl&lt;br /&gt;
 cl &amp;lt; bla.cl &amp;gt; med_values.txt&lt;br /&gt;
 # ls normbdf*fit &amp;gt; norm.list&lt;br /&gt;
 imcomb @norm.list norm.fits comb=med masktype=&amp;quot;!OBJMASK&amp;quot; maskval=0&lt;br /&gt;
 # awk '{print &amp;quot;imarith norm.fits * &amp;quot;$2,&amp;quot; n&amp;quot;$1}' med_values.txt &amp;gt; donorm.cl&lt;br /&gt;
 cl &amp;lt; donorm.cl&lt;br /&gt;
 # awk '{print &amp;quot;imarith&amp;quot;,$1,&amp;quot;-&amp;quot;,&amp;quot;n&amp;quot;$1,&amp;quot;s&amp;quot;$1}' med_values.txt &amp;gt; do.cl&lt;br /&gt;
 cl &amp;lt; do.cl&lt;br /&gt;
    &lt;br /&gt;
 imcomb s@bdfFILTER.list final.fits comb=med offset=&amp;quot;wcs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Surface brightness limit ==&lt;br /&gt;
&lt;br /&gt;
 1. Calibrate the image taking non-saturated stars and not too faint stars: intercept and slope (TOPCAT with SDSS DR12 from Vizier)&lt;br /&gt;
 2. Calculate statistics inside at least 20 (empty, i.e. without objects) boxes of the size of 10&amp;quot; (for example if 1pix=0.396&amp;quot; than 10&amp;quot;~25 pix so boxes = 25 pix &amp;amp;times; 25 pix)&lt;br /&gt;
 3. Take the mean value of the standard deviation inside boxes and it's standard deviation&lt;br /&gt;
 4. Calculate SBmin and SBmax as: &lt;br /&gt;
    SBmax =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;-stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
    SBmin =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;+stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
 where &amp;lt;&amp;amp;sigma;&amp;gt; is the average standard deviation inside boxes and stdev(&amp;lt;&amp;amp;sigma;&amp;gt;) its standard deviation.&lt;br /&gt;
 5. Finally, 1 sigma surface brightness limit (SBlim) is given as:&lt;br /&gt;
    SBlim = (SBmin+SBmax)/2 +/- (SBmax-SBmin)/2&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=132</id>
		<title>CCD data reduction</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=132"/>
		<updated>2024-01-03T20:27:04Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* Astrometry */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic data reduction using IRAF ==&lt;br /&gt;
&lt;br /&gt;
Below is a bash script that creates lists of all images: biases, flats, darks and targets.&lt;br /&gt;
Special case of dark frames of 600sec that Milankovic generates is used&lt;br /&gt;
Last lines create ascii files with median values in flat frames that will be used&lt;br /&gt;
for their normalization.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;&lt;br /&gt;
The script creates reduce.cl IRAF script that should be run from iraf:&lt;br /&gt;
cl &amp;lt; reduce.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
rm *list&lt;br /&gt;
for frame in $(ls *fit); do&lt;br /&gt;
	filterType=$(gethead filter $frame)&lt;br /&gt;
	imageType=$(gethead imagetyp $frame)&lt;br /&gt;
	outFileName=$(echo $imageType | tr '[:upper:]' '[:lower:]')&lt;br /&gt;
	# test if DARK&lt;br /&gt;
	if [ ${imageType} = &amp;quot;DARK&amp;quot; ]; then&lt;br /&gt;
 		exptime=$(gethead exptime $frame | cut -d. -f1) &lt;br /&gt;
 		ls $frame &amp;gt;&amp;gt; ${outFileName}${exptime}&amp;quot;s&amp;quot;.list &lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${exptime}&amp;quot;s&amp;quot;.list&lt;br /&gt;
	else ls $frame &amp;gt;&amp;gt; ${outFileName}${filterType}.list&lt;br /&gt;
	fi&lt;br /&gt;
	# test if LIGHT and create additional lists&lt;br /&gt;
	if [ ${imageType} = &amp;quot;LIGHT&amp;quot; ]; then&lt;br /&gt;
	 	exptime=$(gethead exptime $frame | cut -d. -f1)&lt;br /&gt;
		echo $exptime &amp;gt;&amp;gt; exptime${filterType}.list&lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bdf&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bdf&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	 else if [ ${imageType} = &amp;quot;FLAT&amp;quot; ]; then&lt;br /&gt;
                echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
                echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;nbd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;nbd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	      fi&lt;br /&gt;
	 fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
# Create dark current corresponding to each light frame using exposure time&lt;br /&gt;
for exptime in $(ls exptime*.list); do &lt;br /&gt;
	filter=$(echo $exptime | sed -e s/exptime//g -e s/\.list//g);&lt;br /&gt;
	awk -v filter=${filter} '{print &amp;quot;dc&amp;quot;NR&amp;quot;_&amp;quot;filter&amp;quot;.fits&amp;quot;}' exptime${filter}.list  &amp;gt; dc${filter}.list&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce.cl ]; then rm reduce.cl; fi&lt;br /&gt;
echo &amp;quot;imdelete master_bias,dc_600s,dc_5s,dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bias.list master_bias comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark600s.list - master_bias @bdark600s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark5s.list - master_bias @bdark5s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark5s.list dc_5s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark600s.list dc_600s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl &lt;br /&gt;
echo &amp;quot;imarith dc_600s / 600 dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
&lt;br /&gt;
for flats in $(ls flat*list); do&lt;br /&gt;
        filterType=$(echo $flats | sed s/flat//g | cut -d. -f1)&lt;br /&gt;
        #echo $filterType&lt;br /&gt;
	echo &amp;quot;imarith @flat${filterType}.list - master_bias @bflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imarith @bflat${filterType}.list - dc_5s @bdflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imstat @bdflat${filterType}.list fields=\&amp;quot;image,midpt\&amp;quot; format- &amp;gt; norm${filterType}.txt&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Flat field normalization ==&lt;br /&gt;
&lt;br /&gt;
From terminal (bash):&lt;br /&gt;
&amp;lt;pre&amp;gt;  &lt;br /&gt;
for norm in $(ls norm*txt); do while read line; do echo $line | awk '! /^#/{print &amp;quot;imarith &amp;quot;$1&amp;quot; / &amp;quot;$2,&amp;quot;n&amp;quot;$1}'; done &amp;lt; $norm ; done &amp;gt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From terminal (IRAF):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cl &amp;lt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Calibration of science frames ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash/&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce_images.cl ]; then rm reduce_images.cl; fi&lt;br /&gt;
&lt;br /&gt;
for flat_list in $(ls nbdflat*list); do&lt;br /&gt;
        filter=$(echo ${flat_list} | sed -e s/nbdflat//g -e s/\.list//g);&lt;br /&gt;
        if [ -e light${filter}.list ]; then&lt;br /&gt;
                echo &amp;quot;imcomb @nbdflat${filter}.list master_flat_${filter} comb=med&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith @light${filter}.list - master_bias @blight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith dc_1s * @exptime${filter}.list @dc${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith @blight${filter}.list - @dc${filter}.list @bdlight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith @bdlight${filter}.list / master_flat_${filter} @bdflight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
        fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This script creates IRAF's script reduce_images.cl that should be started from IRAF's terminal. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;&lt;br /&gt;
AFTER the script is run from IRAF terminal, clean up the junk (from bash terminal):&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat blight*list bdlight*list bflat*list bdflat*list nbdflat*list bdark*list dc*.list &amp;gt; tmp_files.list&lt;br /&gt;
rm $(&amp;lt;tmp_files.list)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  BPM &amp;amp; object mask creation ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cat bpmask.cl&lt;br /&gt;
imstat dc_600s field=&amp;quot;image,mean,stddev&amp;quot; for- &amp;gt; hot.txt&lt;br /&gt;
imstat master_flat_FILTER fields=&amp;quot;image,mean&amp;quot; for- &amp;gt; cold.txt&lt;br /&gt;
cl &amp;lt; bpmask.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;gt; b) ? 1 : 0)\&amp;quot; hot&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;($2+3.*$3)*0.75}' hot.txt &amp;gt; hot.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;lt; b) ? 1 : 0)\&amp;quot; cold&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;$2*0.9}' cold.txt &amp;gt; cold.cl&lt;br /&gt;
cl &amp;lt; hot.cl&lt;br /&gt;
cl &amp;lt; cold.cl&lt;br /&gt;
# cat bpm.cl&lt;br /&gt;
imexpr &amp;quot;max(a,b)&amp;quot; bpmFILTER.pl a=hotFILTER.pl b=coldFILTER.pl&lt;br /&gt;
hedit @bdfFILTER.list BPM bpmFILTER.pl add+ ver- &lt;br /&gt;
# sed 's/FILTER/'${filter}'/g'  bpm.cl &amp;gt; dobpm.cl&lt;br /&gt;
cl &amp;lt; dobpm.cl&lt;br /&gt;
  &lt;br /&gt;
# Object masks creation&lt;br /&gt;
nproto&lt;br /&gt;
objmask @bdfFILTER.list @objbdfFILTER.list masks=&amp;quot;!BPM&amp;quot; hsig=2 lsig=2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Astrometry ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh/&lt;br /&gt;
&lt;br /&gt;
for list in $(ls bdflight*list); do&lt;br /&gt;
	while read frame; do &lt;br /&gt;
	ra=$(gethead OBJCTRA $frame | awk '{print $1&amp;quot;:&amp;quot;$2&amp;quot;:&amp;quot;$3}')&lt;br /&gt;
	dec=$(gethead OBJCTDEC $frame | awk '{print $1&amp;quot;:&amp;quot;$2&amp;quot;:&amp;quot;$3}')&lt;br /&gt;
	solve-field &amp;quot;$frame&amp;quot; --ra &amp;quot;$ra&amp;quot; --dec &amp;quot;$dec&amp;quot; --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcs&amp;quot;$frame&amp;quot; -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy --wcs bla.wcs&lt;br /&gt;
	done &amp;lt; $list&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clear up the rest of the junk:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
rm norm*txt master_*fits none* bla.wcs dc*fits *.list&lt;br /&gt;
&lt;br /&gt;
== Supersky flat ==&lt;br /&gt;
 # Creation of super sky flat, normalization to each individual image median background and final stacking&lt;br /&gt;
 # cat stat.cl&lt;br /&gt;
 real mini&lt;br /&gt;
 real sky&lt;br /&gt;
 imstat(&amp;quot;img&amp;quot;,fields=&amp;quot;min&amp;quot;,lower=INDEF,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, mini)&lt;br /&gt;
 imcalc(input=&amp;quot;img,msk&amp;quot;,output=&amp;quot;skyimage&amp;quot;,equals=&amp;quot;if(im2==0.) then im1 else &amp;quot;//mini-0.001,ver-)&lt;br /&gt;
 imstat(&amp;quot;skyimage&amp;quot;,fields=&amp;quot;midpt&amp;quot;,lower=mini-0.001,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, sky)&lt;br /&gt;
 print(&amp;quot;img&amp;quot;,&amp;quot; &amp;quot;,sky)&lt;br /&gt;
 imarith(&amp;quot;img&amp;quot;,&amp;quot;/&amp;quot;,sky,&amp;quot;norm&amp;quot;)&lt;br /&gt;
 imdelete(&amp;quot;skyimage&amp;quot;,yes)&lt;br /&gt;
 # while read line; do img=$(echo $line | awk '{print $1}'); msk=&amp;quot;obj&amp;quot;${img%.*}.pl; rsky=&amp;quot;norm&amp;quot;${img}; cat stat.cl | sed -e 's/img/'${img}'/g' \&lt;br /&gt;
 -e 's/msk/'${msk}'/g'  -e 's/norm/'${rsky}'/g'; done &amp;lt; bdf${filter}.list &amp;gt;  bla.cl&lt;br /&gt;
 cl &amp;lt; bla.cl &amp;gt; med_values.txt&lt;br /&gt;
 # ls normbdf*fit &amp;gt; norm.list&lt;br /&gt;
 imcomb @norm.list norm.fits comb=med masktype=&amp;quot;!OBJMASK&amp;quot; maskval=0&lt;br /&gt;
 # awk '{print &amp;quot;imarith norm.fits * &amp;quot;$2,&amp;quot; n&amp;quot;$1}' med_values.txt &amp;gt; donorm.cl&lt;br /&gt;
 cl &amp;lt; donorm.cl&lt;br /&gt;
 # awk '{print &amp;quot;imarith&amp;quot;,$1,&amp;quot;-&amp;quot;,&amp;quot;n&amp;quot;$1,&amp;quot;s&amp;quot;$1}' med_values.txt &amp;gt; do.cl&lt;br /&gt;
 cl &amp;lt; do.cl&lt;br /&gt;
    &lt;br /&gt;
 imcomb s@bdfFILTER.list final.fits comb=med offset=&amp;quot;wcs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Surface brightness limit ==&lt;br /&gt;
&lt;br /&gt;
 1. Calibrate the image taking non-saturated stars and not too faint stars: intercept and slope (TOPCAT with SDSS DR12 from Vizier)&lt;br /&gt;
 2. Calculate statistics inside at least 20 (empty, i.e. without objects) boxes of the size of 10&amp;quot; (for example if 1pix=0.396&amp;quot; than 10&amp;quot;~25 pix so boxes = 25 pix &amp;amp;times; 25 pix)&lt;br /&gt;
 3. Take the mean value of the standard deviation inside boxes and it's standard deviation&lt;br /&gt;
 4. Calculate SBmin and SBmax as: &lt;br /&gt;
    SBmax =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;-stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
    SBmin =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;+stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
 where &amp;lt;&amp;amp;sigma;&amp;gt; is the average standard deviation inside boxes and stdev(&amp;lt;&amp;amp;sigma;&amp;gt;) its standard deviation.&lt;br /&gt;
 5. Finally, 1 sigma surface brightness limit (SBlim) is given as:&lt;br /&gt;
    SBlim = (SBmin+SBmax)/2 +/- (SBmax-SBmin)/2&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=131</id>
		<title>CCD data reduction</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=131"/>
		<updated>2024-01-03T20:26:30Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* Calibration of science frames */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic data reduction using IRAF ==&lt;br /&gt;
&lt;br /&gt;
Below is a bash script that creates lists of all images: biases, flats, darks and targets.&lt;br /&gt;
Special case of dark frames of 600sec that Milankovic generates is used&lt;br /&gt;
Last lines create ascii files with median values in flat frames that will be used&lt;br /&gt;
for their normalization.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;&lt;br /&gt;
The script creates reduce.cl IRAF script that should be run from iraf:&lt;br /&gt;
cl &amp;lt; reduce.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
rm *list&lt;br /&gt;
for frame in $(ls *fit); do&lt;br /&gt;
	filterType=$(gethead filter $frame)&lt;br /&gt;
	imageType=$(gethead imagetyp $frame)&lt;br /&gt;
	outFileName=$(echo $imageType | tr '[:upper:]' '[:lower:]')&lt;br /&gt;
	# test if DARK&lt;br /&gt;
	if [ ${imageType} = &amp;quot;DARK&amp;quot; ]; then&lt;br /&gt;
 		exptime=$(gethead exptime $frame | cut -d. -f1) &lt;br /&gt;
 		ls $frame &amp;gt;&amp;gt; ${outFileName}${exptime}&amp;quot;s&amp;quot;.list &lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${exptime}&amp;quot;s&amp;quot;.list&lt;br /&gt;
	else ls $frame &amp;gt;&amp;gt; ${outFileName}${filterType}.list&lt;br /&gt;
	fi&lt;br /&gt;
	# test if LIGHT and create additional lists&lt;br /&gt;
	if [ ${imageType} = &amp;quot;LIGHT&amp;quot; ]; then&lt;br /&gt;
	 	exptime=$(gethead exptime $frame | cut -d. -f1)&lt;br /&gt;
		echo $exptime &amp;gt;&amp;gt; exptime${filterType}.list&lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bdf&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bdf&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	 else if [ ${imageType} = &amp;quot;FLAT&amp;quot; ]; then&lt;br /&gt;
                echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
                echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;nbd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;nbd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	      fi&lt;br /&gt;
	 fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
# Create dark current corresponding to each light frame using exposure time&lt;br /&gt;
for exptime in $(ls exptime*.list); do &lt;br /&gt;
	filter=$(echo $exptime | sed -e s/exptime//g -e s/\.list//g);&lt;br /&gt;
	awk -v filter=${filter} '{print &amp;quot;dc&amp;quot;NR&amp;quot;_&amp;quot;filter&amp;quot;.fits&amp;quot;}' exptime${filter}.list  &amp;gt; dc${filter}.list&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce.cl ]; then rm reduce.cl; fi&lt;br /&gt;
echo &amp;quot;imdelete master_bias,dc_600s,dc_5s,dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bias.list master_bias comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark600s.list - master_bias @bdark600s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark5s.list - master_bias @bdark5s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark5s.list dc_5s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark600s.list dc_600s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl &lt;br /&gt;
echo &amp;quot;imarith dc_600s / 600 dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
&lt;br /&gt;
for flats in $(ls flat*list); do&lt;br /&gt;
        filterType=$(echo $flats | sed s/flat//g | cut -d. -f1)&lt;br /&gt;
        #echo $filterType&lt;br /&gt;
	echo &amp;quot;imarith @flat${filterType}.list - master_bias @bflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imarith @bflat${filterType}.list - dc_5s @bdflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imstat @bdflat${filterType}.list fields=\&amp;quot;image,midpt\&amp;quot; format- &amp;gt; norm${filterType}.txt&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Flat field normalization ==&lt;br /&gt;
&lt;br /&gt;
From terminal (bash):&lt;br /&gt;
&amp;lt;pre&amp;gt;  &lt;br /&gt;
for norm in $(ls norm*txt); do while read line; do echo $line | awk '! /^#/{print &amp;quot;imarith &amp;quot;$1&amp;quot; / &amp;quot;$2,&amp;quot;n&amp;quot;$1}'; done &amp;lt; $norm ; done &amp;gt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From terminal (IRAF):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cl &amp;lt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Calibration of science frames ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash/&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce_images.cl ]; then rm reduce_images.cl; fi&lt;br /&gt;
&lt;br /&gt;
for flat_list in $(ls nbdflat*list); do&lt;br /&gt;
        filter=$(echo ${flat_list} | sed -e s/nbdflat//g -e s/\.list//g);&lt;br /&gt;
        if [ -e light${filter}.list ]; then&lt;br /&gt;
                echo &amp;quot;imcomb @nbdflat${filter}.list master_flat_${filter} comb=med&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith @light${filter}.list - master_bias @blight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith dc_1s * @exptime${filter}.list @dc${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith @blight${filter}.list - @dc${filter}.list @bdlight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith @bdlight${filter}.list / master_flat_${filter} @bdflight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
        fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This script creates IRAF's script reduce_images.cl that should be started from IRAF's terminal. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;&lt;br /&gt;
AFTER the script is run from IRAF terminal, clean up the junk (from bash terminal):&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat blight*list bdlight*list bflat*list bdflat*list nbdflat*list bdark*list dc*.list &amp;gt; tmp_files.list&lt;br /&gt;
rm $(&amp;lt;tmp_files.list)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  BPM &amp;amp; object mask creation ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cat bpmask.cl&lt;br /&gt;
imstat dc_600s field=&amp;quot;image,mean,stddev&amp;quot; for- &amp;gt; hot.txt&lt;br /&gt;
imstat master_flat_FILTER fields=&amp;quot;image,mean&amp;quot; for- &amp;gt; cold.txt&lt;br /&gt;
cl &amp;lt; bpmask.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;gt; b) ? 1 : 0)\&amp;quot; hot&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;($2+3.*$3)*0.75}' hot.txt &amp;gt; hot.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;lt; b) ? 1 : 0)\&amp;quot; cold&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;$2*0.9}' cold.txt &amp;gt; cold.cl&lt;br /&gt;
cl &amp;lt; hot.cl&lt;br /&gt;
cl &amp;lt; cold.cl&lt;br /&gt;
# cat bpm.cl&lt;br /&gt;
imexpr &amp;quot;max(a,b)&amp;quot; bpmFILTER.pl a=hotFILTER.pl b=coldFILTER.pl&lt;br /&gt;
hedit @bdfFILTER.list BPM bpmFILTER.pl add+ ver- &lt;br /&gt;
# sed 's/FILTER/'${filter}'/g'  bpm.cl &amp;gt; dobpm.cl&lt;br /&gt;
cl &amp;lt; dobpm.cl&lt;br /&gt;
  &lt;br /&gt;
# Object masks creation&lt;br /&gt;
nproto&lt;br /&gt;
objmask @bdfFILTER.list @objbdfFILTER.list masks=&amp;quot;!BPM&amp;quot; hsig=2 lsig=2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Astrometry ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh/&lt;br /&gt;
&lt;br /&gt;
for list in $(ls bdflight*list); do&lt;br /&gt;
	while read frame; do &lt;br /&gt;
	ra=$(gethead OBJCTRA $frame | awk '{print $1&amp;quot;:&amp;quot;$2&amp;quot;:&amp;quot;$3}')&lt;br /&gt;
	dec=$(gethead OBJCTDEC $frame | awk '{print $1&amp;quot;:&amp;quot;$2&amp;quot;:&amp;quot;$3}')&lt;br /&gt;
	solve-field &amp;quot;$frame&amp;quot; --ra &amp;quot;$ra&amp;quot; --dec &amp;quot;$dec&amp;quot; --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcs&amp;quot;$frame&amp;quot; -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy --wcs bla.wcs&lt;br /&gt;
	done &amp;lt; $list&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Supersky flat ==&lt;br /&gt;
 # Creation of super sky flat, normalization to each individual image median background and final stacking&lt;br /&gt;
 # cat stat.cl&lt;br /&gt;
 real mini&lt;br /&gt;
 real sky&lt;br /&gt;
 imstat(&amp;quot;img&amp;quot;,fields=&amp;quot;min&amp;quot;,lower=INDEF,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, mini)&lt;br /&gt;
 imcalc(input=&amp;quot;img,msk&amp;quot;,output=&amp;quot;skyimage&amp;quot;,equals=&amp;quot;if(im2==0.) then im1 else &amp;quot;//mini-0.001,ver-)&lt;br /&gt;
 imstat(&amp;quot;skyimage&amp;quot;,fields=&amp;quot;midpt&amp;quot;,lower=mini-0.001,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, sky)&lt;br /&gt;
 print(&amp;quot;img&amp;quot;,&amp;quot; &amp;quot;,sky)&lt;br /&gt;
 imarith(&amp;quot;img&amp;quot;,&amp;quot;/&amp;quot;,sky,&amp;quot;norm&amp;quot;)&lt;br /&gt;
 imdelete(&amp;quot;skyimage&amp;quot;,yes)&lt;br /&gt;
 # while read line; do img=$(echo $line | awk '{print $1}'); msk=&amp;quot;obj&amp;quot;${img%.*}.pl; rsky=&amp;quot;norm&amp;quot;${img}; cat stat.cl | sed -e 's/img/'${img}'/g' \&lt;br /&gt;
 -e 's/msk/'${msk}'/g'  -e 's/norm/'${rsky}'/g'; done &amp;lt; bdf${filter}.list &amp;gt;  bla.cl&lt;br /&gt;
 cl &amp;lt; bla.cl &amp;gt; med_values.txt&lt;br /&gt;
 # ls normbdf*fit &amp;gt; norm.list&lt;br /&gt;
 imcomb @norm.list norm.fits comb=med masktype=&amp;quot;!OBJMASK&amp;quot; maskval=0&lt;br /&gt;
 # awk '{print &amp;quot;imarith norm.fits * &amp;quot;$2,&amp;quot; n&amp;quot;$1}' med_values.txt &amp;gt; donorm.cl&lt;br /&gt;
 cl &amp;lt; donorm.cl&lt;br /&gt;
 # awk '{print &amp;quot;imarith&amp;quot;,$1,&amp;quot;-&amp;quot;,&amp;quot;n&amp;quot;$1,&amp;quot;s&amp;quot;$1}' med_values.txt &amp;gt; do.cl&lt;br /&gt;
 cl &amp;lt; do.cl&lt;br /&gt;
    &lt;br /&gt;
 imcomb s@bdfFILTER.list final.fits comb=med offset=&amp;quot;wcs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Surface brightness limit ==&lt;br /&gt;
&lt;br /&gt;
 1. Calibrate the image taking non-saturated stars and not too faint stars: intercept and slope (TOPCAT with SDSS DR12 from Vizier)&lt;br /&gt;
 2. Calculate statistics inside at least 20 (empty, i.e. without objects) boxes of the size of 10&amp;quot; (for example if 1pix=0.396&amp;quot; than 10&amp;quot;~25 pix so boxes = 25 pix &amp;amp;times; 25 pix)&lt;br /&gt;
 3. Take the mean value of the standard deviation inside boxes and it's standard deviation&lt;br /&gt;
 4. Calculate SBmin and SBmax as: &lt;br /&gt;
    SBmax =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;-stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
    SBmin =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;+stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
 where &amp;lt;&amp;amp;sigma;&amp;gt; is the average standard deviation inside boxes and stdev(&amp;lt;&amp;amp;sigma;&amp;gt;) its standard deviation.&lt;br /&gt;
 5. Finally, 1 sigma surface brightness limit (SBlim) is given as:&lt;br /&gt;
    SBlim = (SBmin+SBmax)/2 +/- (SBmax-SBmin)/2&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=130</id>
		<title>CCD data reduction</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=130"/>
		<updated>2024-01-03T20:25:55Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* Calibration of science frames */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic data reduction using IRAF ==&lt;br /&gt;
&lt;br /&gt;
Below is a bash script that creates lists of all images: biases, flats, darks and targets.&lt;br /&gt;
Special case of dark frames of 600sec that Milankovic generates is used&lt;br /&gt;
Last lines create ascii files with median values in flat frames that will be used&lt;br /&gt;
for their normalization.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;&lt;br /&gt;
The script creates reduce.cl IRAF script that should be run from iraf:&lt;br /&gt;
cl &amp;lt; reduce.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
rm *list&lt;br /&gt;
for frame in $(ls *fit); do&lt;br /&gt;
	filterType=$(gethead filter $frame)&lt;br /&gt;
	imageType=$(gethead imagetyp $frame)&lt;br /&gt;
	outFileName=$(echo $imageType | tr '[:upper:]' '[:lower:]')&lt;br /&gt;
	# test if DARK&lt;br /&gt;
	if [ ${imageType} = &amp;quot;DARK&amp;quot; ]; then&lt;br /&gt;
 		exptime=$(gethead exptime $frame | cut -d. -f1) &lt;br /&gt;
 		ls $frame &amp;gt;&amp;gt; ${outFileName}${exptime}&amp;quot;s&amp;quot;.list &lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${exptime}&amp;quot;s&amp;quot;.list&lt;br /&gt;
	else ls $frame &amp;gt;&amp;gt; ${outFileName}${filterType}.list&lt;br /&gt;
	fi&lt;br /&gt;
	# test if LIGHT and create additional lists&lt;br /&gt;
	if [ ${imageType} = &amp;quot;LIGHT&amp;quot; ]; then&lt;br /&gt;
	 	exptime=$(gethead exptime $frame | cut -d. -f1)&lt;br /&gt;
		echo $exptime &amp;gt;&amp;gt; exptime${filterType}.list&lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bdf&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bdf&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	 else if [ ${imageType} = &amp;quot;FLAT&amp;quot; ]; then&lt;br /&gt;
                echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
                echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;nbd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;nbd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	      fi&lt;br /&gt;
	 fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
# Create dark current corresponding to each light frame using exposure time&lt;br /&gt;
for exptime in $(ls exptime*.list); do &lt;br /&gt;
	filter=$(echo $exptime | sed -e s/exptime//g -e s/\.list//g);&lt;br /&gt;
	awk -v filter=${filter} '{print &amp;quot;dc&amp;quot;NR&amp;quot;_&amp;quot;filter&amp;quot;.fits&amp;quot;}' exptime${filter}.list  &amp;gt; dc${filter}.list&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce.cl ]; then rm reduce.cl; fi&lt;br /&gt;
echo &amp;quot;imdelete master_bias,dc_600s,dc_5s,dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bias.list master_bias comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark600s.list - master_bias @bdark600s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark5s.list - master_bias @bdark5s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark5s.list dc_5s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark600s.list dc_600s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl &lt;br /&gt;
echo &amp;quot;imarith dc_600s / 600 dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
&lt;br /&gt;
for flats in $(ls flat*list); do&lt;br /&gt;
        filterType=$(echo $flats | sed s/flat//g | cut -d. -f1)&lt;br /&gt;
        #echo $filterType&lt;br /&gt;
	echo &amp;quot;imarith @flat${filterType}.list - master_bias @bflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imarith @bflat${filterType}.list - dc_5s @bdflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imstat @bdflat${filterType}.list fields=\&amp;quot;image,midpt\&amp;quot; format- &amp;gt; norm${filterType}.txt&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Flat field normalization ==&lt;br /&gt;
&lt;br /&gt;
From terminal (bash):&lt;br /&gt;
&amp;lt;pre&amp;gt;  &lt;br /&gt;
for norm in $(ls norm*txt); do while read line; do echo $line | awk '! /^#/{print &amp;quot;imarith &amp;quot;$1&amp;quot; / &amp;quot;$2,&amp;quot;n&amp;quot;$1}'; done &amp;lt; $norm ; done &amp;gt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From terminal (IRAF):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cl &amp;lt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Calibration of science frames ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash/&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce_images.cl ]; then rm reduce_images.cl; fi&lt;br /&gt;
&lt;br /&gt;
for flat_list in $(ls nbdflat*list); do&lt;br /&gt;
        filter=$(echo ${flat_list} | sed -e s/nbdflat//g -e s/\.list//g);&lt;br /&gt;
        if [ -e light${filter}.list ]; then&lt;br /&gt;
                echo &amp;quot;imcomb @nbdflat${filter}.list master_flat_${filter} comb=med&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith @light${filter}.list - master_bias @blight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith dc_1s * @exptime${filter}.list @dc${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith @blight${filter}.list - @dc${filter}.list @bdlight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith @bdlight${filter}.list / master_flat_${filter} @bdflight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
        fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This script creates IRAF's script reduce_images.cl that should be started from IRAF's terminal. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;&lt;br /&gt;
AFTER the script is run from IRAF terminal, clean up the junk (from bash terminal):&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat blight*list bdlight*list bflat*list bdflat*list nbdflat*list bdark*list dc*.list &amp;gt; tmp_files.list&lt;br /&gt;
rm $(&amp;lt;tmp_files.list)&lt;br /&gt;
rm norm*txt master_*fits none* bla.wcs dc*fits *.list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  BPM &amp;amp; object mask creation ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cat bpmask.cl&lt;br /&gt;
imstat dc_600s field=&amp;quot;image,mean,stddev&amp;quot; for- &amp;gt; hot.txt&lt;br /&gt;
imstat master_flat_FILTER fields=&amp;quot;image,mean&amp;quot; for- &amp;gt; cold.txt&lt;br /&gt;
cl &amp;lt; bpmask.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;gt; b) ? 1 : 0)\&amp;quot; hot&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;($2+3.*$3)*0.75}' hot.txt &amp;gt; hot.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;lt; b) ? 1 : 0)\&amp;quot; cold&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;$2*0.9}' cold.txt &amp;gt; cold.cl&lt;br /&gt;
cl &amp;lt; hot.cl&lt;br /&gt;
cl &amp;lt; cold.cl&lt;br /&gt;
# cat bpm.cl&lt;br /&gt;
imexpr &amp;quot;max(a,b)&amp;quot; bpmFILTER.pl a=hotFILTER.pl b=coldFILTER.pl&lt;br /&gt;
hedit @bdfFILTER.list BPM bpmFILTER.pl add+ ver- &lt;br /&gt;
# sed 's/FILTER/'${filter}'/g'  bpm.cl &amp;gt; dobpm.cl&lt;br /&gt;
cl &amp;lt; dobpm.cl&lt;br /&gt;
  &lt;br /&gt;
# Object masks creation&lt;br /&gt;
nproto&lt;br /&gt;
objmask @bdfFILTER.list @objbdfFILTER.list masks=&amp;quot;!BPM&amp;quot; hsig=2 lsig=2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Astrometry ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh/&lt;br /&gt;
&lt;br /&gt;
for list in $(ls bdflight*list); do&lt;br /&gt;
	while read frame; do &lt;br /&gt;
	ra=$(gethead OBJCTRA $frame | awk '{print $1&amp;quot;:&amp;quot;$2&amp;quot;:&amp;quot;$3}')&lt;br /&gt;
	dec=$(gethead OBJCTDEC $frame | awk '{print $1&amp;quot;:&amp;quot;$2&amp;quot;:&amp;quot;$3}')&lt;br /&gt;
	solve-field &amp;quot;$frame&amp;quot; --ra &amp;quot;$ra&amp;quot; --dec &amp;quot;$dec&amp;quot; --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcs&amp;quot;$frame&amp;quot; -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy --wcs bla.wcs&lt;br /&gt;
	done &amp;lt; $list&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Supersky flat ==&lt;br /&gt;
 # Creation of super sky flat, normalization to each individual image median background and final stacking&lt;br /&gt;
 # cat stat.cl&lt;br /&gt;
 real mini&lt;br /&gt;
 real sky&lt;br /&gt;
 imstat(&amp;quot;img&amp;quot;,fields=&amp;quot;min&amp;quot;,lower=INDEF,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, mini)&lt;br /&gt;
 imcalc(input=&amp;quot;img,msk&amp;quot;,output=&amp;quot;skyimage&amp;quot;,equals=&amp;quot;if(im2==0.) then im1 else &amp;quot;//mini-0.001,ver-)&lt;br /&gt;
 imstat(&amp;quot;skyimage&amp;quot;,fields=&amp;quot;midpt&amp;quot;,lower=mini-0.001,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, sky)&lt;br /&gt;
 print(&amp;quot;img&amp;quot;,&amp;quot; &amp;quot;,sky)&lt;br /&gt;
 imarith(&amp;quot;img&amp;quot;,&amp;quot;/&amp;quot;,sky,&amp;quot;norm&amp;quot;)&lt;br /&gt;
 imdelete(&amp;quot;skyimage&amp;quot;,yes)&lt;br /&gt;
 # while read line; do img=$(echo $line | awk '{print $1}'); msk=&amp;quot;obj&amp;quot;${img%.*}.pl; rsky=&amp;quot;norm&amp;quot;${img}; cat stat.cl | sed -e 's/img/'${img}'/g' \&lt;br /&gt;
 -e 's/msk/'${msk}'/g'  -e 's/norm/'${rsky}'/g'; done &amp;lt; bdf${filter}.list &amp;gt;  bla.cl&lt;br /&gt;
 cl &amp;lt; bla.cl &amp;gt; med_values.txt&lt;br /&gt;
 # ls normbdf*fit &amp;gt; norm.list&lt;br /&gt;
 imcomb @norm.list norm.fits comb=med masktype=&amp;quot;!OBJMASK&amp;quot; maskval=0&lt;br /&gt;
 # awk '{print &amp;quot;imarith norm.fits * &amp;quot;$2,&amp;quot; n&amp;quot;$1}' med_values.txt &amp;gt; donorm.cl&lt;br /&gt;
 cl &amp;lt; donorm.cl&lt;br /&gt;
 # awk '{print &amp;quot;imarith&amp;quot;,$1,&amp;quot;-&amp;quot;,&amp;quot;n&amp;quot;$1,&amp;quot;s&amp;quot;$1}' med_values.txt &amp;gt; do.cl&lt;br /&gt;
 cl &amp;lt; do.cl&lt;br /&gt;
    &lt;br /&gt;
 imcomb s@bdfFILTER.list final.fits comb=med offset=&amp;quot;wcs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Surface brightness limit ==&lt;br /&gt;
&lt;br /&gt;
 1. Calibrate the image taking non-saturated stars and not too faint stars: intercept and slope (TOPCAT with SDSS DR12 from Vizier)&lt;br /&gt;
 2. Calculate statistics inside at least 20 (empty, i.e. without objects) boxes of the size of 10&amp;quot; (for example if 1pix=0.396&amp;quot; than 10&amp;quot;~25 pix so boxes = 25 pix &amp;amp;times; 25 pix)&lt;br /&gt;
 3. Take the mean value of the standard deviation inside boxes and it's standard deviation&lt;br /&gt;
 4. Calculate SBmin and SBmax as: &lt;br /&gt;
    SBmax =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;-stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
    SBmin =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;+stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
 where &amp;lt;&amp;amp;sigma;&amp;gt; is the average standard deviation inside boxes and stdev(&amp;lt;&amp;amp;sigma;&amp;gt;) its standard deviation.&lt;br /&gt;
 5. Finally, 1 sigma surface brightness limit (SBlim) is given as:&lt;br /&gt;
    SBlim = (SBmin+SBmax)/2 +/- (SBmax-SBmin)/2&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=129</id>
		<title>CCD data reduction</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=129"/>
		<updated>2024-01-03T20:22:20Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* Calibration of science frames */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic data reduction using IRAF ==&lt;br /&gt;
&lt;br /&gt;
Below is a bash script that creates lists of all images: biases, flats, darks and targets.&lt;br /&gt;
Special case of dark frames of 600sec that Milankovic generates is used&lt;br /&gt;
Last lines create ascii files with median values in flat frames that will be used&lt;br /&gt;
for their normalization.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;&lt;br /&gt;
The script creates reduce.cl IRAF script that should be run from iraf:&lt;br /&gt;
cl &amp;lt; reduce.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
rm *list&lt;br /&gt;
for frame in $(ls *fit); do&lt;br /&gt;
	filterType=$(gethead filter $frame)&lt;br /&gt;
	imageType=$(gethead imagetyp $frame)&lt;br /&gt;
	outFileName=$(echo $imageType | tr '[:upper:]' '[:lower:]')&lt;br /&gt;
	# test if DARK&lt;br /&gt;
	if [ ${imageType} = &amp;quot;DARK&amp;quot; ]; then&lt;br /&gt;
 		exptime=$(gethead exptime $frame | cut -d. -f1) &lt;br /&gt;
 		ls $frame &amp;gt;&amp;gt; ${outFileName}${exptime}&amp;quot;s&amp;quot;.list &lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${exptime}&amp;quot;s&amp;quot;.list&lt;br /&gt;
	else ls $frame &amp;gt;&amp;gt; ${outFileName}${filterType}.list&lt;br /&gt;
	fi&lt;br /&gt;
	# test if LIGHT and create additional lists&lt;br /&gt;
	if [ ${imageType} = &amp;quot;LIGHT&amp;quot; ]; then&lt;br /&gt;
	 	exptime=$(gethead exptime $frame | cut -d. -f1)&lt;br /&gt;
		echo $exptime &amp;gt;&amp;gt; exptime${filterType}.list&lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bdf&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bdf&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	 else if [ ${imageType} = &amp;quot;FLAT&amp;quot; ]; then&lt;br /&gt;
                echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
                echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;nbd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;nbd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	      fi&lt;br /&gt;
	 fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
# Create dark current corresponding to each light frame using exposure time&lt;br /&gt;
for exptime in $(ls exptime*.list); do &lt;br /&gt;
	filter=$(echo $exptime | sed -e s/exptime//g -e s/\.list//g);&lt;br /&gt;
	awk -v filter=${filter} '{print &amp;quot;dc&amp;quot;NR&amp;quot;_&amp;quot;filter&amp;quot;.fits&amp;quot;}' exptime${filter}.list  &amp;gt; dc${filter}.list&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce.cl ]; then rm reduce.cl; fi&lt;br /&gt;
echo &amp;quot;imdelete master_bias,dc_600s,dc_5s,dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bias.list master_bias comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark600s.list - master_bias @bdark600s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark5s.list - master_bias @bdark5s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark5s.list dc_5s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark600s.list dc_600s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl &lt;br /&gt;
echo &amp;quot;imarith dc_600s / 600 dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
&lt;br /&gt;
for flats in $(ls flat*list); do&lt;br /&gt;
        filterType=$(echo $flats | sed s/flat//g | cut -d. -f1)&lt;br /&gt;
        #echo $filterType&lt;br /&gt;
	echo &amp;quot;imarith @flat${filterType}.list - master_bias @bflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imarith @bflat${filterType}.list - dc_5s @bdflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imstat @bdflat${filterType}.list fields=\&amp;quot;image,midpt\&amp;quot; format- &amp;gt; norm${filterType}.txt&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Flat field normalization ==&lt;br /&gt;
&lt;br /&gt;
From terminal (bash):&lt;br /&gt;
&amp;lt;pre&amp;gt;  &lt;br /&gt;
for norm in $(ls norm*txt); do while read line; do echo $line | awk '! /^#/{print &amp;quot;imarith &amp;quot;$1&amp;quot; / &amp;quot;$2,&amp;quot;n&amp;quot;$1}'; done &amp;lt; $norm ; done &amp;gt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From terminal (IRAF):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cl &amp;lt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Calibration of science frames ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash/&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce_images.cl ]; then rm reduce_images.cl; fi&lt;br /&gt;
&lt;br /&gt;
for flat_list in $(ls nbdflat*list); do&lt;br /&gt;
        filter=$(echo ${flat_list} | sed -e s/nbdflat//g -e s/\.list//g);&lt;br /&gt;
        if [ -e light${filter}.list ]; then&lt;br /&gt;
                echo &amp;quot;imcomb @nbdflat${filter}.list master_flat_${filter} comb=med&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith @light${filter}.list - master_bias @blight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith dc_1s * @exptime${filter}.list @dc${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith @blight${filter}.list - @dc${filter}.list @bdlight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith @bdlight${filter}.list / master_flat_${filter} @bdflight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
        fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This script creates IRAF's script reduce_images.cl that should be started from IRAF's terminal. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;&lt;br /&gt;
AFTER the script is run from IRAF terminal, clean up the junk (from bash terminal):&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat blight*list bdlight*list bflat*list bdflat*list nbdflat*list bdark*list dc*.list norm*txt &amp;gt; tmp_files.list&lt;br /&gt;
rm $(&amp;lt;tmp_files.list)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  BPM &amp;amp; object mask creation ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cat bpmask.cl&lt;br /&gt;
imstat dc_600s field=&amp;quot;image,mean,stddev&amp;quot; for- &amp;gt; hot.txt&lt;br /&gt;
imstat master_flat_FILTER fields=&amp;quot;image,mean&amp;quot; for- &amp;gt; cold.txt&lt;br /&gt;
cl &amp;lt; bpmask.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;gt; b) ? 1 : 0)\&amp;quot; hot&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;($2+3.*$3)*0.75}' hot.txt &amp;gt; hot.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;lt; b) ? 1 : 0)\&amp;quot; cold&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;$2*0.9}' cold.txt &amp;gt; cold.cl&lt;br /&gt;
cl &amp;lt; hot.cl&lt;br /&gt;
cl &amp;lt; cold.cl&lt;br /&gt;
# cat bpm.cl&lt;br /&gt;
imexpr &amp;quot;max(a,b)&amp;quot; bpmFILTER.pl a=hotFILTER.pl b=coldFILTER.pl&lt;br /&gt;
hedit @bdfFILTER.list BPM bpmFILTER.pl add+ ver- &lt;br /&gt;
# sed 's/FILTER/'${filter}'/g'  bpm.cl &amp;gt; dobpm.cl&lt;br /&gt;
cl &amp;lt; dobpm.cl&lt;br /&gt;
  &lt;br /&gt;
# Object masks creation&lt;br /&gt;
nproto&lt;br /&gt;
objmask @bdfFILTER.list @objbdfFILTER.list masks=&amp;quot;!BPM&amp;quot; hsig=2 lsig=2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Astrometry ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh/&lt;br /&gt;
&lt;br /&gt;
for list in $(ls bdflight*list); do&lt;br /&gt;
	while read frame; do &lt;br /&gt;
	ra=$(gethead OBJCTRA $frame | awk '{print $1&amp;quot;:&amp;quot;$2&amp;quot;:&amp;quot;$3}')&lt;br /&gt;
	dec=$(gethead OBJCTDEC $frame | awk '{print $1&amp;quot;:&amp;quot;$2&amp;quot;:&amp;quot;$3}')&lt;br /&gt;
	solve-field &amp;quot;$frame&amp;quot; --ra &amp;quot;$ra&amp;quot; --dec &amp;quot;$dec&amp;quot; --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcs&amp;quot;$frame&amp;quot; -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy --wcs bla.wcs&lt;br /&gt;
	done &amp;lt; $list&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Supersky flat ==&lt;br /&gt;
 # Creation of super sky flat, normalization to each individual image median background and final stacking&lt;br /&gt;
 # cat stat.cl&lt;br /&gt;
 real mini&lt;br /&gt;
 real sky&lt;br /&gt;
 imstat(&amp;quot;img&amp;quot;,fields=&amp;quot;min&amp;quot;,lower=INDEF,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, mini)&lt;br /&gt;
 imcalc(input=&amp;quot;img,msk&amp;quot;,output=&amp;quot;skyimage&amp;quot;,equals=&amp;quot;if(im2==0.) then im1 else &amp;quot;//mini-0.001,ver-)&lt;br /&gt;
 imstat(&amp;quot;skyimage&amp;quot;,fields=&amp;quot;midpt&amp;quot;,lower=mini-0.001,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, sky)&lt;br /&gt;
 print(&amp;quot;img&amp;quot;,&amp;quot; &amp;quot;,sky)&lt;br /&gt;
 imarith(&amp;quot;img&amp;quot;,&amp;quot;/&amp;quot;,sky,&amp;quot;norm&amp;quot;)&lt;br /&gt;
 imdelete(&amp;quot;skyimage&amp;quot;,yes)&lt;br /&gt;
 # while read line; do img=$(echo $line | awk '{print $1}'); msk=&amp;quot;obj&amp;quot;${img%.*}.pl; rsky=&amp;quot;norm&amp;quot;${img}; cat stat.cl | sed -e 's/img/'${img}'/g' \&lt;br /&gt;
 -e 's/msk/'${msk}'/g'  -e 's/norm/'${rsky}'/g'; done &amp;lt; bdf${filter}.list &amp;gt;  bla.cl&lt;br /&gt;
 cl &amp;lt; bla.cl &amp;gt; med_values.txt&lt;br /&gt;
 # ls normbdf*fit &amp;gt; norm.list&lt;br /&gt;
 imcomb @norm.list norm.fits comb=med masktype=&amp;quot;!OBJMASK&amp;quot; maskval=0&lt;br /&gt;
 # awk '{print &amp;quot;imarith norm.fits * &amp;quot;$2,&amp;quot; n&amp;quot;$1}' med_values.txt &amp;gt; donorm.cl&lt;br /&gt;
 cl &amp;lt; donorm.cl&lt;br /&gt;
 # awk '{print &amp;quot;imarith&amp;quot;,$1,&amp;quot;-&amp;quot;,&amp;quot;n&amp;quot;$1,&amp;quot;s&amp;quot;$1}' med_values.txt &amp;gt; do.cl&lt;br /&gt;
 cl &amp;lt; do.cl&lt;br /&gt;
    &lt;br /&gt;
 imcomb s@bdfFILTER.list final.fits comb=med offset=&amp;quot;wcs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Surface brightness limit ==&lt;br /&gt;
&lt;br /&gt;
 1. Calibrate the image taking non-saturated stars and not too faint stars: intercept and slope (TOPCAT with SDSS DR12 from Vizier)&lt;br /&gt;
 2. Calculate statistics inside at least 20 (empty, i.e. without objects) boxes of the size of 10&amp;quot; (for example if 1pix=0.396&amp;quot; than 10&amp;quot;~25 pix so boxes = 25 pix &amp;amp;times; 25 pix)&lt;br /&gt;
 3. Take the mean value of the standard deviation inside boxes and it's standard deviation&lt;br /&gt;
 4. Calculate SBmin and SBmax as: &lt;br /&gt;
    SBmax =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;-stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
    SBmin =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;+stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
 where &amp;lt;&amp;amp;sigma;&amp;gt; is the average standard deviation inside boxes and stdev(&amp;lt;&amp;amp;sigma;&amp;gt;) its standard deviation.&lt;br /&gt;
 5. Finally, 1 sigma surface brightness limit (SBlim) is given as:&lt;br /&gt;
    SBlim = (SBmin+SBmax)/2 +/- (SBmax-SBmin)/2&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=Astro_links&amp;diff=128</id>
		<title>Astro links</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=Astro_links&amp;diff=128"/>
		<updated>2023-12-15T09:07:43Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* STSDAS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== IRAF ===&lt;br /&gt;
&lt;br /&gt;
alias goiraf='xgterm -ls -g 82x30+0+0 -bg bisque1 -fn fixed -fg gray16 -e cl &amp;amp;' # put into ~/.bashrc&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== [http://stsdas.stsci.edu/irafx STSDAS] ===&lt;br /&gt;
&lt;br /&gt;
In Ubuntu install IRAF using Synaptic. Than download STSDAS from http://stsdas.stsci.edu/irafx/stsdas.linux.tar.gz. Unpack, go to stsci_iraf_x dir and start ./install_helper. Export IRAF: export iraf='/home/user/.iraf/' from the terminal and start installer again. The following text will apear:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
reset   tables          = /home/user/stsci_iraf_x/tables/&lt;br /&gt;
task    tables.pkg      = tables$tables.cl&lt;br /&gt;
if (access(&amp;quot;tables$lib&amp;quot;)) reset helpdb= ( envget(&amp;quot;helpdb&amp;quot;) + &amp;quot;,tables$lib/helpdb.mip&amp;quot; )  &lt;br /&gt;
&lt;br /&gt;
reset   stsdas          = /home/user/stsci_iraf_x/stsdas/&lt;br /&gt;
task    stsdas.pkg      = stsdas$stsdas.cl&lt;br /&gt;
task    apropos         = stsdas$apropos.cl&lt;br /&gt;
if (access(&amp;quot;stsdas$lib&amp;quot;)) reset helpdb= ( envget(&amp;quot;helpdb&amp;quot;) + &amp;quot;,stsdas$lib/helpdb.mip&amp;quot; )  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the text, start xgterm from terminal, then irafcl in the xgterm and when iraf starts paste these few lines. Just check if the stsci_iraf_x folder is in the right place. Afterwards, you can normally use stsdas and tables.&lt;br /&gt;
&lt;br /&gt;
BETTER option, although it might not work is to the following:&lt;br /&gt;
&lt;br /&gt;
edit your extern.pkg file:&lt;br /&gt;
&lt;br /&gt;
sudo gedit /iraf/iraf/unix/hlib/extern.pkg&lt;br /&gt;
&lt;br /&gt;
With the following lines:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
reset tables = /iraf/extern/tables/&lt;br /&gt;
task tables.pkg = tables$tables.cl&lt;br /&gt;
reset stsdas = /iraf/extern/stsdas/&lt;br /&gt;
task stsdas.pkg = stsdas$stsdas.cl&lt;br /&gt;
&lt;br /&gt;
reset helpdb = &amp;quot;lib$helpdb.mip\&lt;br /&gt;
,noao$lib/helpdb.mip\&lt;br /&gt;
,tables$lib/helpdb.mip\&lt;br /&gt;
,stsdas$lib/helpdb.mip\&lt;br /&gt;
&amp;quot;&lt;br /&gt;
keep&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font color=red&amp;gt;!!! Copy the missing text and uncomment existing but leave exactly the same spaces as in the original extern.pkg file - copy and paste blank fields (I cannot mimic that here) !!!&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [http://www.stsci.edu/resources/software_hardware/pyraf/current/download PYRAF] ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font color=red&amp;gt;''This pyraf goes with iraf, so first you have to install [http://wiki.ipb.ac.rs/index.php/IrafInstallation iraf].&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Download the latest pyraf release:&lt;br /&gt;
&lt;br /&gt;
wget http://stsdas.stsci.edu/download/pyraf/pyraf-1.9.tar.gz . # Check if this is still the latest release!!!&amp;lt;br&amp;gt;&lt;br /&gt;
tar xvf pyraf-1.9.tar.gz&amp;lt;br&amp;gt;&lt;br /&gt;
rm pyraf-1.9.tar.gz&amp;lt;br&amp;gt;&lt;br /&gt;
cd pytools&amp;lt;br&amp;gt;&lt;br /&gt;
sudo python setup.py install # This should go smoothly &amp;lt;br&amp;gt;&lt;br /&gt;
cd ../pyraf-1.9&amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install libx11-dev # Solved: Error &amp;quot;X11/X.h: No such file or directory&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
sudo apt-get install python-tk&amp;lt;br&amp;gt;&lt;br /&gt;
sudo python setup.py install &lt;br /&gt;
* In the case of error &amp;quot;Python.h missing&amp;quot; install the latest &amp;lt;font color=blue&amp;gt;python&amp;lt;/font&amp;gt; and &amp;lt;font color=blue&amp;gt;python-dev&amp;lt;/font&amp;gt; (python2.5 and python2.5-dev for Ubuntu 8.04) using synaptic&amp;lt;br&amp;gt;&lt;br /&gt;
* Check if you have &amp;lt;font color=blue&amp;gt;gcc&amp;lt;/font&amp;gt; and &amp;lt;font color=blue&amp;gt;gfortran&amp;lt;/font&amp;gt;, if not install:&amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install gcc&amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install gfortran&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Try to run again &amp;lt;font color=green&amp;gt; sudo python setup.py install &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* And run &amp;lt;font color=green&amp;gt; sudo python setup.py install &amp;lt;/font&amp;gt; again. If it reports that numpy is missing go to [http://sourceforge.net/projects/numpy/files/ SourceForge] and download source:&lt;br /&gt;
cd ../.&amp;lt;br&amp;gt;&lt;br /&gt;
wget http://sourceforge.net/projects/numpy/files/NumPy/1.4.1/numpy-1.4.1.tar.gz/download . # Check if this is the latest version&amp;lt;br&amp;gt;&lt;br /&gt;
tar xvf numpy-1.4.1.tar.gz&amp;lt;br&amp;gt;&lt;br /&gt;
cd numpy-1.4.1/&lt;br /&gt;
* Follow the instructions in INSTALL.txt, that are for Ubuntu 8.04. - 10.04:&lt;br /&gt;
sudo apt-get install libatlas-base-dev &amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install libatlas3gf-sse2 &amp;lt;br&amp;gt;&lt;br /&gt;
sudo python setup.py install &amp;lt;br&amp;gt;&lt;br /&gt;
* Go back to pyraf-1.9 directory and repeat&lt;br /&gt;
sudo python setup.py install &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should work!!!&lt;br /&gt;
&lt;br /&gt;
=== [http://heasarc.gsfc.nasa.gov/fitsio/ CFITSIO] ===&lt;br /&gt;
&lt;br /&gt;
CFITSIO is a library of C and Fortran subroutines for reading and writing data files in FITS. Installation under Linux (Ubuntu 8.04) with/without multithreading.&lt;br /&gt;
* Installation under Ubuntu 8.04&lt;br /&gt;
 cd /home/user/&lt;br /&gt;
 wget ftp://heasarc.gsfc.nasa.gov/software/fitsio/c/cfitsio3240.tar.gz . # Check for the latest version under [http://heasarc.gsfc.nasa.gov/fitsio/ Unix .tar file]&lt;br /&gt;
 tar zxvf cfitsio3240.tar.gz&lt;br /&gt;
 cd cfitsio/&lt;br /&gt;
  ./configure CC=gcc &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;--enable-reentrant&amp;lt;/font&amp;gt; # &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt; WITH MULTITHREAD&amp;lt;/font&amp;gt;&lt;br /&gt;
  make shared  # &amp;lt;small&amp;gt;builds a shared or dynamic version of the CFITSIO library saving the disk space, memory &amp;lt;/small&amp;gt; &lt;br /&gt;
  # &amp;lt;small&amp;gt; and enables easier maintenance since a new version of the shared library can be installed without relinking all the software that uses it &amp;lt;/small&amp;gt;&lt;br /&gt;
  make install&lt;br /&gt;
  make testprog&lt;br /&gt;
  ./testprog &amp;gt; testprog.lis&lt;br /&gt;
  diff testprog.lis testprog.out # There should not be any output &lt;br /&gt;
  cmp testprog.fit testprog.std  # There should not be any output&lt;br /&gt;
  sudo apt-get install happycoders-libsocket happycoders-libsocket-dev&lt;br /&gt;
  cd /usr/lib/&lt;br /&gt;
  sudo ln -s /usr/lib/happycoders/libsocket.so .&lt;br /&gt;
&lt;br /&gt;
* Proper linking (add in .bashrc file)&lt;br /&gt;
&lt;br /&gt;
 C_INCLUDE_PATH=/home/user/cfitsio/include&lt;br /&gt;
 LIBRARY_PATH=/home/user/cfitsio/lib&lt;br /&gt;
 export C_INCLUDE_PATH LIBRARY_PATH&lt;br /&gt;
&lt;br /&gt;
* Testing&lt;br /&gt;
 cd /home/user/cfitsio/&lt;br /&gt;
 make speed # measures the maximum throughput (in MB per second) for writing and reading FITS files with CFITSIO &lt;br /&gt;
 ./speed&lt;br /&gt;
 make listhead # lists all the header keywords in any FITS file&lt;br /&gt;
 ./listhead&lt;br /&gt;
 make fitscopy # copies any FITS file&lt;br /&gt;
 ./fitscopy&lt;br /&gt;
 make cookbook # a sample program that performs common read and write operations on a FITS file.&lt;br /&gt;
 ./cookbook&lt;br /&gt;
&lt;br /&gt;
* Compiling &lt;br /&gt;
** #include &amp;quot;fitsio.h&amp;quot; # Include in any .c program to use cfitsio library&lt;br /&gt;
  gcc -o iter_a iter_a.c -lcfitsio -lm &lt;br /&gt;
  ./iter_a&lt;br /&gt;
&lt;br /&gt;
The typical libraries that need to be added are &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lm&amp;lt;/font&amp;gt; (the math library) and &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lnsl&amp;lt;/font&amp;gt; and &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lsocket&amp;lt;/font&amp;gt; (needed only for FTP and HTTP file access).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[http://www.stsci.edu/resources/software_hardware/pyfits Pyfits] can be easily installed from the source:&lt;br /&gt;
 wget  http://www.stsci.edu/resources/software_hardware/pyfits/pyfits-2.3.1.tar.gz &lt;br /&gt;
 tar xvf pyfits-2.3.1.tar.gz&lt;br /&gt;
 cd pyfits-2.3.1/&lt;br /&gt;
 sudo  python setup.py install # To install in Python's site-packages directory (recommended)&lt;br /&gt;
OR &lt;br /&gt;
 sudo python setup.py install --prefix=&amp;quot;/destination/directory/&amp;quot;  # Wherever you want&lt;br /&gt;
&lt;br /&gt;
== [http://tdc-www.harvard.edu/software/wcstools/index.html WCSTools] ==&lt;br /&gt;
&lt;br /&gt;
WCSTools is a package of programs and a library of utility subroutines for setting and using the world coordinate systems (WCS) in the headers of the most common astronomical image formats, FITS and IRAF .imh, to relate image pixels to sky coordinates. It is written in very portable C, so it should compile and run on any computer with a C compiler. &lt;br /&gt;
&lt;br /&gt;
* WCS Tools installation&lt;br /&gt;
&lt;br /&gt;
Download the latest version of WCS tools, which is at the moment (August, 2010) [http://tdc-www.harvard.edu/software/wcstools/wcstools-3.8.1.tar.gz wcstools-3.8.1]. Unpack it:&lt;br /&gt;
 tar xvf wcstools-3.8.1.tar.gz&lt;br /&gt;
 cd wcstools-3.8.1&lt;br /&gt;
 export CC=gcc&lt;br /&gt;
 sudo make&lt;br /&gt;
 sudo mkdir -p /usr/wcstools/&lt;br /&gt;
 sudo mv bin /usr/wcstools &lt;br /&gt;
Open your .basrc file (in your home dir) and add the following lines:&lt;br /&gt;
 #WCSTools&lt;br /&gt;
 PATH=$PATH:/usr/wcstools/bin&lt;br /&gt;
 export PATH &lt;br /&gt;
Restart the xterm or type: &lt;br /&gt;
 source ~/.bashrc&lt;br /&gt;
&lt;br /&gt;
Now you have all wcstool commands available from the terminal:&lt;br /&gt;
 &lt;br /&gt;
 addpix   delwcs    getdate  imextract  imsmooth  keyhead  simpos   xy2sky&lt;br /&gt;
 bincat   edhead    getfits  imfill     imstack   nedpos   sky2xy&lt;br /&gt;
 char2sp  filename  gethead  imhead     imstar    newfits  skycoor&lt;br /&gt;
 conpix   fileroot  getpix   immatch    imwcs     remap    sp2char&lt;br /&gt;
 cphead   filext    gettab   imresize   isfits    scat     subpix&lt;br /&gt;
 crlf     fixpix    i2f      imrot      isnum     sethead  sumpix&lt;br /&gt;
 delhead  getcol    imcat    imsize     isrange   setpix   wcshead&lt;br /&gt;
&lt;br /&gt;
Enjoy!&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=Astro_links&amp;diff=127</id>
		<title>Astro links</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=Astro_links&amp;diff=127"/>
		<updated>2023-12-15T09:06:18Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* STSDAS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== [http://stsdas.stsci.edu/irafx STSDAS] ===&lt;br /&gt;
&lt;br /&gt;
In Ubuntu install IRAF using Synaptic. Than download STSDAS from http://stsdas.stsci.edu/irafx/stsdas.linux.tar.gz. Unpack, go to stsci_iraf_x dir and start ./install_helper. Export IRAF: export iraf='/home/user/.iraf/' from the terminal and start installer again. The following text will apear:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
reset   tables          = /home/user/stsci_iraf_x/tables/&lt;br /&gt;
task    tables.pkg      = tables$tables.cl&lt;br /&gt;
if (access(&amp;quot;tables$lib&amp;quot;)) reset helpdb= ( envget(&amp;quot;helpdb&amp;quot;) + &amp;quot;,tables$lib/helpdb.mip&amp;quot; )  &lt;br /&gt;
&lt;br /&gt;
reset   stsdas          = /home/user/stsci_iraf_x/stsdas/&lt;br /&gt;
task    stsdas.pkg      = stsdas$stsdas.cl&lt;br /&gt;
task    apropos         = stsdas$apropos.cl&lt;br /&gt;
if (access(&amp;quot;stsdas$lib&amp;quot;)) reset helpdb= ( envget(&amp;quot;helpdb&amp;quot;) + &amp;quot;,stsdas$lib/helpdb.mip&amp;quot; )  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the text, start xgterm from terminal, then irafcl in the xgterm and when iraf starts paste these few lines. Just check if the stsci_iraf_x folder is in the right place. Afterwards, you can normally use stsdas and tables.&lt;br /&gt;
&lt;br /&gt;
BETTER option, although it might not work is to the following:&lt;br /&gt;
&lt;br /&gt;
edit your extern.pkg file:&lt;br /&gt;
&lt;br /&gt;
sudo gedit /iraf/iraf/unix/hlib/extern.pkg&lt;br /&gt;
&lt;br /&gt;
With the following lines:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
reset tables = /iraf/extern/tables/&lt;br /&gt;
task tables.pkg = tables$tables.cl&lt;br /&gt;
reset stsdas = /iraf/extern/stsdas/&lt;br /&gt;
task stsdas.pkg = stsdas$stsdas.cl&lt;br /&gt;
&lt;br /&gt;
reset helpdb = &amp;quot;lib$helpdb.mip\&lt;br /&gt;
,noao$lib/helpdb.mip\&lt;br /&gt;
,tables$lib/helpdb.mip\&lt;br /&gt;
,stsdas$lib/helpdb.mip\&lt;br /&gt;
&amp;quot;&lt;br /&gt;
keep&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font color=red&amp;gt;!!! Copy the missing text and uncomment existing but leave exactly the same spaces as in the original extern.pkg file - copy and paste blank fields (I cannot mimic that here) !!!&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [http://www.stsci.edu/resources/software_hardware/pyraf/current/download PYRAF] ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font color=red&amp;gt;''This pyraf goes with iraf, so first you have to install [http://wiki.ipb.ac.rs/index.php/IrafInstallation iraf].&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Download the latest pyraf release:&lt;br /&gt;
&lt;br /&gt;
wget http://stsdas.stsci.edu/download/pyraf/pyraf-1.9.tar.gz . # Check if this is still the latest release!!!&amp;lt;br&amp;gt;&lt;br /&gt;
tar xvf pyraf-1.9.tar.gz&amp;lt;br&amp;gt;&lt;br /&gt;
rm pyraf-1.9.tar.gz&amp;lt;br&amp;gt;&lt;br /&gt;
cd pytools&amp;lt;br&amp;gt;&lt;br /&gt;
sudo python setup.py install # This should go smoothly &amp;lt;br&amp;gt;&lt;br /&gt;
cd ../pyraf-1.9&amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install libx11-dev # Solved: Error &amp;quot;X11/X.h: No such file or directory&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
sudo apt-get install python-tk&amp;lt;br&amp;gt;&lt;br /&gt;
sudo python setup.py install &lt;br /&gt;
* In the case of error &amp;quot;Python.h missing&amp;quot; install the latest &amp;lt;font color=blue&amp;gt;python&amp;lt;/font&amp;gt; and &amp;lt;font color=blue&amp;gt;python-dev&amp;lt;/font&amp;gt; (python2.5 and python2.5-dev for Ubuntu 8.04) using synaptic&amp;lt;br&amp;gt;&lt;br /&gt;
* Check if you have &amp;lt;font color=blue&amp;gt;gcc&amp;lt;/font&amp;gt; and &amp;lt;font color=blue&amp;gt;gfortran&amp;lt;/font&amp;gt;, if not install:&amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install gcc&amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install gfortran&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Try to run again &amp;lt;font color=green&amp;gt; sudo python setup.py install &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* And run &amp;lt;font color=green&amp;gt; sudo python setup.py install &amp;lt;/font&amp;gt; again. If it reports that numpy is missing go to [http://sourceforge.net/projects/numpy/files/ SourceForge] and download source:&lt;br /&gt;
cd ../.&amp;lt;br&amp;gt;&lt;br /&gt;
wget http://sourceforge.net/projects/numpy/files/NumPy/1.4.1/numpy-1.4.1.tar.gz/download . # Check if this is the latest version&amp;lt;br&amp;gt;&lt;br /&gt;
tar xvf numpy-1.4.1.tar.gz&amp;lt;br&amp;gt;&lt;br /&gt;
cd numpy-1.4.1/&lt;br /&gt;
* Follow the instructions in INSTALL.txt, that are for Ubuntu 8.04. - 10.04:&lt;br /&gt;
sudo apt-get install libatlas-base-dev &amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install libatlas3gf-sse2 &amp;lt;br&amp;gt;&lt;br /&gt;
sudo python setup.py install &amp;lt;br&amp;gt;&lt;br /&gt;
* Go back to pyraf-1.9 directory and repeat&lt;br /&gt;
sudo python setup.py install &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should work!!!&lt;br /&gt;
&lt;br /&gt;
=== [http://heasarc.gsfc.nasa.gov/fitsio/ CFITSIO] ===&lt;br /&gt;
&lt;br /&gt;
CFITSIO is a library of C and Fortran subroutines for reading and writing data files in FITS. Installation under Linux (Ubuntu 8.04) with/without multithreading.&lt;br /&gt;
* Installation under Ubuntu 8.04&lt;br /&gt;
 cd /home/user/&lt;br /&gt;
 wget ftp://heasarc.gsfc.nasa.gov/software/fitsio/c/cfitsio3240.tar.gz . # Check for the latest version under [http://heasarc.gsfc.nasa.gov/fitsio/ Unix .tar file]&lt;br /&gt;
 tar zxvf cfitsio3240.tar.gz&lt;br /&gt;
 cd cfitsio/&lt;br /&gt;
  ./configure CC=gcc &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;--enable-reentrant&amp;lt;/font&amp;gt; # &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt; WITH MULTITHREAD&amp;lt;/font&amp;gt;&lt;br /&gt;
  make shared  # &amp;lt;small&amp;gt;builds a shared or dynamic version of the CFITSIO library saving the disk space, memory &amp;lt;/small&amp;gt; &lt;br /&gt;
  # &amp;lt;small&amp;gt; and enables easier maintenance since a new version of the shared library can be installed without relinking all the software that uses it &amp;lt;/small&amp;gt;&lt;br /&gt;
  make install&lt;br /&gt;
  make testprog&lt;br /&gt;
  ./testprog &amp;gt; testprog.lis&lt;br /&gt;
  diff testprog.lis testprog.out # There should not be any output &lt;br /&gt;
  cmp testprog.fit testprog.std  # There should not be any output&lt;br /&gt;
  sudo apt-get install happycoders-libsocket happycoders-libsocket-dev&lt;br /&gt;
  cd /usr/lib/&lt;br /&gt;
  sudo ln -s /usr/lib/happycoders/libsocket.so .&lt;br /&gt;
&lt;br /&gt;
* Proper linking (add in .bashrc file)&lt;br /&gt;
&lt;br /&gt;
 C_INCLUDE_PATH=/home/user/cfitsio/include&lt;br /&gt;
 LIBRARY_PATH=/home/user/cfitsio/lib&lt;br /&gt;
 export C_INCLUDE_PATH LIBRARY_PATH&lt;br /&gt;
&lt;br /&gt;
* Testing&lt;br /&gt;
 cd /home/user/cfitsio/&lt;br /&gt;
 make speed # measures the maximum throughput (in MB per second) for writing and reading FITS files with CFITSIO &lt;br /&gt;
 ./speed&lt;br /&gt;
 make listhead # lists all the header keywords in any FITS file&lt;br /&gt;
 ./listhead&lt;br /&gt;
 make fitscopy # copies any FITS file&lt;br /&gt;
 ./fitscopy&lt;br /&gt;
 make cookbook # a sample program that performs common read and write operations on a FITS file.&lt;br /&gt;
 ./cookbook&lt;br /&gt;
&lt;br /&gt;
* Compiling &lt;br /&gt;
** #include &amp;quot;fitsio.h&amp;quot; # Include in any .c program to use cfitsio library&lt;br /&gt;
  gcc -o iter_a iter_a.c -lcfitsio -lm &lt;br /&gt;
  ./iter_a&lt;br /&gt;
&lt;br /&gt;
The typical libraries that need to be added are &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lm&amp;lt;/font&amp;gt; (the math library) and &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lnsl&amp;lt;/font&amp;gt; and &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lsocket&amp;lt;/font&amp;gt; (needed only for FTP and HTTP file access).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[http://www.stsci.edu/resources/software_hardware/pyfits Pyfits] can be easily installed from the source:&lt;br /&gt;
 wget  http://www.stsci.edu/resources/software_hardware/pyfits/pyfits-2.3.1.tar.gz &lt;br /&gt;
 tar xvf pyfits-2.3.1.tar.gz&lt;br /&gt;
 cd pyfits-2.3.1/&lt;br /&gt;
 sudo  python setup.py install # To install in Python's site-packages directory (recommended)&lt;br /&gt;
OR &lt;br /&gt;
 sudo python setup.py install --prefix=&amp;quot;/destination/directory/&amp;quot;  # Wherever you want&lt;br /&gt;
&lt;br /&gt;
== [http://tdc-www.harvard.edu/software/wcstools/index.html WCSTools] ==&lt;br /&gt;
&lt;br /&gt;
WCSTools is a package of programs and a library of utility subroutines for setting and using the world coordinate systems (WCS) in the headers of the most common astronomical image formats, FITS and IRAF .imh, to relate image pixels to sky coordinates. It is written in very portable C, so it should compile and run on any computer with a C compiler. &lt;br /&gt;
&lt;br /&gt;
* WCS Tools installation&lt;br /&gt;
&lt;br /&gt;
Download the latest version of WCS tools, which is at the moment (August, 2010) [http://tdc-www.harvard.edu/software/wcstools/wcstools-3.8.1.tar.gz wcstools-3.8.1]. Unpack it:&lt;br /&gt;
 tar xvf wcstools-3.8.1.tar.gz&lt;br /&gt;
 cd wcstools-3.8.1&lt;br /&gt;
 export CC=gcc&lt;br /&gt;
 sudo make&lt;br /&gt;
 sudo mkdir -p /usr/wcstools/&lt;br /&gt;
 sudo mv bin /usr/wcstools &lt;br /&gt;
Open your .basrc file (in your home dir) and add the following lines:&lt;br /&gt;
 #WCSTools&lt;br /&gt;
 PATH=$PATH:/usr/wcstools/bin&lt;br /&gt;
 export PATH &lt;br /&gt;
Restart the xterm or type: &lt;br /&gt;
 source ~/.bashrc&lt;br /&gt;
&lt;br /&gt;
Now you have all wcstool commands available from the terminal:&lt;br /&gt;
 &lt;br /&gt;
 addpix   delwcs    getdate  imextract  imsmooth  keyhead  simpos   xy2sky&lt;br /&gt;
 bincat   edhead    getfits  imfill     imstack   nedpos   sky2xy&lt;br /&gt;
 char2sp  filename  gethead  imhead     imstar    newfits  skycoor&lt;br /&gt;
 conpix   fileroot  getpix   immatch    imwcs     remap    sp2char&lt;br /&gt;
 cphead   filext    gettab   imresize   isfits    scat     subpix&lt;br /&gt;
 crlf     fixpix    i2f      imrot      isnum     sethead  sumpix&lt;br /&gt;
 delhead  getcol    imcat    imsize     isrange   setpix   wcshead&lt;br /&gt;
&lt;br /&gt;
Enjoy!&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=Astro_links&amp;diff=126</id>
		<title>Astro links</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=Astro_links&amp;diff=126"/>
		<updated>2023-12-15T09:05:56Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* STSDAS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== [http://stsdas.stsci.edu/irafx STSDAS] ===&lt;br /&gt;
&lt;br /&gt;
In Ubuntu install IRAF using Synaptic. Than download STSDAS from http://stsdas.stsci.edu/irafx/stsdas.linux.tar.gz. Unpack, go to stsci_iraf_x dir and start ./install_helper. Export IRAF: export iraf='/home/user/.iraf/' from the terminal and start installer again. The following text will apear:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
reset   tables          = /home/user/stsci_iraf_x/tables/&lt;br /&gt;
task    tables.pkg      = tables$tables.cl&lt;br /&gt;
if (access(&amp;quot;tables$lib&amp;quot;)) reset helpdb= ( envget(&amp;quot;helpdb&amp;quot;) + &amp;quot;,tables$lib/helpdb.mip&amp;quot; )  &lt;br /&gt;
&lt;br /&gt;
reset   stsdas          = /home/user/stsci_iraf_x/stsdas/&lt;br /&gt;
task    stsdas.pkg      = stsdas$stsdas.cl&lt;br /&gt;
task    apropos         = stsdas$apropos.cl&lt;br /&gt;
if (access(&amp;quot;stsdas$lib&amp;quot;)) reset helpdb= ( envget(&amp;quot;helpdb&amp;quot;) + &amp;quot;,stsdas$lib/helpdb.mip&amp;quot; )  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the text, start xgterm from terminal, then irafcl in the xgterm and when iraf starts paste these few lines. Just check if the stsci_iraf_x folder is in the right place. Afterwards, you can normally use stsdas and tables.&lt;br /&gt;
&lt;br /&gt;
BETTER option, although it might not work is to the following:&lt;br /&gt;
&lt;br /&gt;
edit your extern.pkg file:&lt;br /&gt;
&lt;br /&gt;
sudo gedit /iraf/iraf/unix/hlib/extern.pkg&lt;br /&gt;
&lt;br /&gt;
With the following lines:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
reset tables = /iraf/extern/tables/&lt;br /&gt;
task tables.pkg = tables$tables.cl&lt;br /&gt;
reset stsdas = /iraf/extern/stsdas/&lt;br /&gt;
task stsdas.pkg = stsdas$stsdas.cl&lt;br /&gt;
&lt;br /&gt;
reset helpdb = &amp;quot;lib$helpdb.mip\&lt;br /&gt;
,noao$lib/helpdb.mip\&lt;br /&gt;
,tables$lib/helpdb.mip\&lt;br /&gt;
,stsdas$lib/helpdb.mip\&lt;br /&gt;
&amp;quot;&lt;br /&gt;
keep&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font color=red&amp;gt;!!! Copy the missing text and uncomment existing but leave exactly the same spaces as in the original extern.pkg file - copy and paste blank fields (I cannot mimic that here) !!!&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [http://www.stsci.edu/resources/software_hardware/pyraf/current/download PYRAF] ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font color=red&amp;gt;''This pyraf goes with iraf, so first you have to install [http://wiki.ipb.ac.rs/index.php/IrafInstallation iraf].&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Download the latest pyraf release:&lt;br /&gt;
&lt;br /&gt;
wget http://stsdas.stsci.edu/download/pyraf/pyraf-1.9.tar.gz . # Check if this is still the latest release!!!&amp;lt;br&amp;gt;&lt;br /&gt;
tar xvf pyraf-1.9.tar.gz&amp;lt;br&amp;gt;&lt;br /&gt;
rm pyraf-1.9.tar.gz&amp;lt;br&amp;gt;&lt;br /&gt;
cd pytools&amp;lt;br&amp;gt;&lt;br /&gt;
sudo python setup.py install # This should go smoothly &amp;lt;br&amp;gt;&lt;br /&gt;
cd ../pyraf-1.9&amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install libx11-dev # Solved: Error &amp;quot;X11/X.h: No such file or directory&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
sudo apt-get install python-tk&amp;lt;br&amp;gt;&lt;br /&gt;
sudo python setup.py install &lt;br /&gt;
* In the case of error &amp;quot;Python.h missing&amp;quot; install the latest &amp;lt;font color=blue&amp;gt;python&amp;lt;/font&amp;gt; and &amp;lt;font color=blue&amp;gt;python-dev&amp;lt;/font&amp;gt; (python2.5 and python2.5-dev for Ubuntu 8.04) using synaptic&amp;lt;br&amp;gt;&lt;br /&gt;
* Check if you have &amp;lt;font color=blue&amp;gt;gcc&amp;lt;/font&amp;gt; and &amp;lt;font color=blue&amp;gt;gfortran&amp;lt;/font&amp;gt;, if not install:&amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install gcc&amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install gfortran&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Try to run again &amp;lt;font color=green&amp;gt; sudo python setup.py install &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* And run &amp;lt;font color=green&amp;gt; sudo python setup.py install &amp;lt;/font&amp;gt; again. If it reports that numpy is missing go to [http://sourceforge.net/projects/numpy/files/ SourceForge] and download source:&lt;br /&gt;
cd ../.&amp;lt;br&amp;gt;&lt;br /&gt;
wget http://sourceforge.net/projects/numpy/files/NumPy/1.4.1/numpy-1.4.1.tar.gz/download . # Check if this is the latest version&amp;lt;br&amp;gt;&lt;br /&gt;
tar xvf numpy-1.4.1.tar.gz&amp;lt;br&amp;gt;&lt;br /&gt;
cd numpy-1.4.1/&lt;br /&gt;
* Follow the instructions in INSTALL.txt, that are for Ubuntu 8.04. - 10.04:&lt;br /&gt;
sudo apt-get install libatlas-base-dev &amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install libatlas3gf-sse2 &amp;lt;br&amp;gt;&lt;br /&gt;
sudo python setup.py install &amp;lt;br&amp;gt;&lt;br /&gt;
* Go back to pyraf-1.9 directory and repeat&lt;br /&gt;
sudo python setup.py install &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should work!!!&lt;br /&gt;
&lt;br /&gt;
=== [http://heasarc.gsfc.nasa.gov/fitsio/ CFITSIO] ===&lt;br /&gt;
&lt;br /&gt;
CFITSIO is a library of C and Fortran subroutines for reading and writing data files in FITS. Installation under Linux (Ubuntu 8.04) with/without multithreading.&lt;br /&gt;
* Installation under Ubuntu 8.04&lt;br /&gt;
 cd /home/user/&lt;br /&gt;
 wget ftp://heasarc.gsfc.nasa.gov/software/fitsio/c/cfitsio3240.tar.gz . # Check for the latest version under [http://heasarc.gsfc.nasa.gov/fitsio/ Unix .tar file]&lt;br /&gt;
 tar zxvf cfitsio3240.tar.gz&lt;br /&gt;
 cd cfitsio/&lt;br /&gt;
  ./configure CC=gcc &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;--enable-reentrant&amp;lt;/font&amp;gt; # &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt; WITH MULTITHREAD&amp;lt;/font&amp;gt;&lt;br /&gt;
  make shared  # &amp;lt;small&amp;gt;builds a shared or dynamic version of the CFITSIO library saving the disk space, memory &amp;lt;/small&amp;gt; &lt;br /&gt;
  # &amp;lt;small&amp;gt; and enables easier maintenance since a new version of the shared library can be installed without relinking all the software that uses it &amp;lt;/small&amp;gt;&lt;br /&gt;
  make install&lt;br /&gt;
  make testprog&lt;br /&gt;
  ./testprog &amp;gt; testprog.lis&lt;br /&gt;
  diff testprog.lis testprog.out # There should not be any output &lt;br /&gt;
  cmp testprog.fit testprog.std  # There should not be any output&lt;br /&gt;
  sudo apt-get install happycoders-libsocket happycoders-libsocket-dev&lt;br /&gt;
  cd /usr/lib/&lt;br /&gt;
  sudo ln -s /usr/lib/happycoders/libsocket.so .&lt;br /&gt;
&lt;br /&gt;
* Proper linking (add in .bashrc file)&lt;br /&gt;
&lt;br /&gt;
 C_INCLUDE_PATH=/home/user/cfitsio/include&lt;br /&gt;
 LIBRARY_PATH=/home/user/cfitsio/lib&lt;br /&gt;
 export C_INCLUDE_PATH LIBRARY_PATH&lt;br /&gt;
&lt;br /&gt;
* Testing&lt;br /&gt;
 cd /home/user/cfitsio/&lt;br /&gt;
 make speed # measures the maximum throughput (in MB per second) for writing and reading FITS files with CFITSIO &lt;br /&gt;
 ./speed&lt;br /&gt;
 make listhead # lists all the header keywords in any FITS file&lt;br /&gt;
 ./listhead&lt;br /&gt;
 make fitscopy # copies any FITS file&lt;br /&gt;
 ./fitscopy&lt;br /&gt;
 make cookbook # a sample program that performs common read and write operations on a FITS file.&lt;br /&gt;
 ./cookbook&lt;br /&gt;
&lt;br /&gt;
* Compiling &lt;br /&gt;
** #include &amp;quot;fitsio.h&amp;quot; # Include in any .c program to use cfitsio library&lt;br /&gt;
  gcc -o iter_a iter_a.c -lcfitsio -lm &lt;br /&gt;
  ./iter_a&lt;br /&gt;
&lt;br /&gt;
The typical libraries that need to be added are &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lm&amp;lt;/font&amp;gt; (the math library) and &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lnsl&amp;lt;/font&amp;gt; and &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lsocket&amp;lt;/font&amp;gt; (needed only for FTP and HTTP file access).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[http://www.stsci.edu/resources/software_hardware/pyfits Pyfits] can be easily installed from the source:&lt;br /&gt;
 wget  http://www.stsci.edu/resources/software_hardware/pyfits/pyfits-2.3.1.tar.gz &lt;br /&gt;
 tar xvf pyfits-2.3.1.tar.gz&lt;br /&gt;
 cd pyfits-2.3.1/&lt;br /&gt;
 sudo  python setup.py install # To install in Python's site-packages directory (recommended)&lt;br /&gt;
OR &lt;br /&gt;
 sudo python setup.py install --prefix=&amp;quot;/destination/directory/&amp;quot;  # Wherever you want&lt;br /&gt;
&lt;br /&gt;
== [http://tdc-www.harvard.edu/software/wcstools/index.html WCSTools] ==&lt;br /&gt;
&lt;br /&gt;
WCSTools is a package of programs and a library of utility subroutines for setting and using the world coordinate systems (WCS) in the headers of the most common astronomical image formats, FITS and IRAF .imh, to relate image pixels to sky coordinates. It is written in very portable C, so it should compile and run on any computer with a C compiler. &lt;br /&gt;
&lt;br /&gt;
* WCS Tools installation&lt;br /&gt;
&lt;br /&gt;
Download the latest version of WCS tools, which is at the moment (August, 2010) [http://tdc-www.harvard.edu/software/wcstools/wcstools-3.8.1.tar.gz wcstools-3.8.1]. Unpack it:&lt;br /&gt;
 tar xvf wcstools-3.8.1.tar.gz&lt;br /&gt;
 cd wcstools-3.8.1&lt;br /&gt;
 export CC=gcc&lt;br /&gt;
 sudo make&lt;br /&gt;
 sudo mkdir -p /usr/wcstools/&lt;br /&gt;
 sudo mv bin /usr/wcstools &lt;br /&gt;
Open your .basrc file (in your home dir) and add the following lines:&lt;br /&gt;
 #WCSTools&lt;br /&gt;
 PATH=$PATH:/usr/wcstools/bin&lt;br /&gt;
 export PATH &lt;br /&gt;
Restart the xterm or type: &lt;br /&gt;
 source ~/.bashrc&lt;br /&gt;
&lt;br /&gt;
Now you have all wcstool commands available from the terminal:&lt;br /&gt;
 &lt;br /&gt;
 addpix   delwcs    getdate  imextract  imsmooth  keyhead  simpos   xy2sky&lt;br /&gt;
 bincat   edhead    getfits  imfill     imstack   nedpos   sky2xy&lt;br /&gt;
 char2sp  filename  gethead  imhead     imstar    newfits  skycoor&lt;br /&gt;
 conpix   fileroot  getpix   immatch    imwcs     remap    sp2char&lt;br /&gt;
 cphead   filext    gettab   imresize   isfits    scat     subpix&lt;br /&gt;
 crlf     fixpix    i2f      imrot      isnum     sethead  sumpix&lt;br /&gt;
 delhead  getcol    imcat    imsize     isrange   setpix   wcshead&lt;br /&gt;
&lt;br /&gt;
Enjoy!&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=Astro_links&amp;diff=125</id>
		<title>Astro links</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=Astro_links&amp;diff=125"/>
		<updated>2023-12-15T09:05:25Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* STSDAS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== [http://stsdas.stsci.edu/irafx STSDAS] ===&lt;br /&gt;
&lt;br /&gt;
In Ubuntu install IRAF using Synaptic. Than download STSDAS from http://stsdas.stsci.edu/irafx/stsdas.linux.tar.gz. Unpack, go to stsci_iraf_x dir and start ./install_helper. Export IRAF: export iraf='/home/user/.iraf/' from the terminal and start installer again. The following text will apear:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
reset   tables          = /home/user/stsci_iraf_x/tables/&lt;br /&gt;
task    tables.pkg      = tables$tables.cl&lt;br /&gt;
if (access(&amp;quot;tables$lib&amp;quot;)) reset helpdb= ( envget(&amp;quot;helpdb&amp;quot;) + &amp;quot;,tables$lib/helpdb.mip&amp;quot; )  &lt;br /&gt;
&lt;br /&gt;
reset   stsdas          = /home/user/stsci_iraf_x/stsdas/&lt;br /&gt;
task    stsdas.pkg      = stsdas$stsdas.cl&lt;br /&gt;
task    apropos         = stsdas$apropos.cl&lt;br /&gt;
if (access(&amp;quot;stsdas$lib&amp;quot;)) reset helpdb= ( envget(&amp;quot;helpdb&amp;quot;) + &amp;quot;,stsdas$lib/helpdb.mip&amp;quot; )  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the text, start xgterm from terminal, then irafcl in the xgterm and when iraf starts paste these few lines. Just check if the stsci_iraf_x folder is in the right place. Afterwards, you can normally use stsdas and tables.&lt;br /&gt;
&lt;br /&gt;
BETTER option, although it might not work is to the following:&lt;br /&gt;
&lt;br /&gt;
# edit your extern.pkg file:&lt;br /&gt;
sudo gedit /iraf/iraf/unix/hlib/extern.pkg&lt;br /&gt;
&lt;br /&gt;
With the following lines:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
reset tables = /iraf/extern/tables/&lt;br /&gt;
task tables.pkg = tables$tables.cl&lt;br /&gt;
reset stsdas = /iraf/extern/stsdas/&lt;br /&gt;
task stsdas.pkg = stsdas$stsdas.cl&lt;br /&gt;
&lt;br /&gt;
reset helpdb = &amp;quot;lib$helpdb.mip\&lt;br /&gt;
,noao$lib/helpdb.mip\&lt;br /&gt;
,tables$lib/helpdb.mip\&lt;br /&gt;
,stsdas$lib/helpdb.mip\&lt;br /&gt;
&amp;quot;&lt;br /&gt;
keep&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# &amp;lt;font color=red&amp;gt;!!! Copy the missing text and uncomment existing but leave exactly the same spaces as in the original extern.pkg file - copy and paste blank fields (I cannot mimic that here) !!!&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [http://www.stsci.edu/resources/software_hardware/pyraf/current/download PYRAF] ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font color=red&amp;gt;''This pyraf goes with iraf, so first you have to install [http://wiki.ipb.ac.rs/index.php/IrafInstallation iraf].&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Download the latest pyraf release:&lt;br /&gt;
&lt;br /&gt;
wget http://stsdas.stsci.edu/download/pyraf/pyraf-1.9.tar.gz . # Check if this is still the latest release!!!&amp;lt;br&amp;gt;&lt;br /&gt;
tar xvf pyraf-1.9.tar.gz&amp;lt;br&amp;gt;&lt;br /&gt;
rm pyraf-1.9.tar.gz&amp;lt;br&amp;gt;&lt;br /&gt;
cd pytools&amp;lt;br&amp;gt;&lt;br /&gt;
sudo python setup.py install # This should go smoothly &amp;lt;br&amp;gt;&lt;br /&gt;
cd ../pyraf-1.9&amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install libx11-dev # Solved: Error &amp;quot;X11/X.h: No such file or directory&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
sudo apt-get install python-tk&amp;lt;br&amp;gt;&lt;br /&gt;
sudo python setup.py install &lt;br /&gt;
* In the case of error &amp;quot;Python.h missing&amp;quot; install the latest &amp;lt;font color=blue&amp;gt;python&amp;lt;/font&amp;gt; and &amp;lt;font color=blue&amp;gt;python-dev&amp;lt;/font&amp;gt; (python2.5 and python2.5-dev for Ubuntu 8.04) using synaptic&amp;lt;br&amp;gt;&lt;br /&gt;
* Check if you have &amp;lt;font color=blue&amp;gt;gcc&amp;lt;/font&amp;gt; and &amp;lt;font color=blue&amp;gt;gfortran&amp;lt;/font&amp;gt;, if not install:&amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install gcc&amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install gfortran&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Try to run again &amp;lt;font color=green&amp;gt; sudo python setup.py install &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* And run &amp;lt;font color=green&amp;gt; sudo python setup.py install &amp;lt;/font&amp;gt; again. If it reports that numpy is missing go to [http://sourceforge.net/projects/numpy/files/ SourceForge] and download source:&lt;br /&gt;
cd ../.&amp;lt;br&amp;gt;&lt;br /&gt;
wget http://sourceforge.net/projects/numpy/files/NumPy/1.4.1/numpy-1.4.1.tar.gz/download . # Check if this is the latest version&amp;lt;br&amp;gt;&lt;br /&gt;
tar xvf numpy-1.4.1.tar.gz&amp;lt;br&amp;gt;&lt;br /&gt;
cd numpy-1.4.1/&lt;br /&gt;
* Follow the instructions in INSTALL.txt, that are for Ubuntu 8.04. - 10.04:&lt;br /&gt;
sudo apt-get install libatlas-base-dev &amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install libatlas3gf-sse2 &amp;lt;br&amp;gt;&lt;br /&gt;
sudo python setup.py install &amp;lt;br&amp;gt;&lt;br /&gt;
* Go back to pyraf-1.9 directory and repeat&lt;br /&gt;
sudo python setup.py install &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should work!!!&lt;br /&gt;
&lt;br /&gt;
=== [http://heasarc.gsfc.nasa.gov/fitsio/ CFITSIO] ===&lt;br /&gt;
&lt;br /&gt;
CFITSIO is a library of C and Fortran subroutines for reading and writing data files in FITS. Installation under Linux (Ubuntu 8.04) with/without multithreading.&lt;br /&gt;
* Installation under Ubuntu 8.04&lt;br /&gt;
 cd /home/user/&lt;br /&gt;
 wget ftp://heasarc.gsfc.nasa.gov/software/fitsio/c/cfitsio3240.tar.gz . # Check for the latest version under [http://heasarc.gsfc.nasa.gov/fitsio/ Unix .tar file]&lt;br /&gt;
 tar zxvf cfitsio3240.tar.gz&lt;br /&gt;
 cd cfitsio/&lt;br /&gt;
  ./configure CC=gcc &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;--enable-reentrant&amp;lt;/font&amp;gt; # &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt; WITH MULTITHREAD&amp;lt;/font&amp;gt;&lt;br /&gt;
  make shared  # &amp;lt;small&amp;gt;builds a shared or dynamic version of the CFITSIO library saving the disk space, memory &amp;lt;/small&amp;gt; &lt;br /&gt;
  # &amp;lt;small&amp;gt; and enables easier maintenance since a new version of the shared library can be installed without relinking all the software that uses it &amp;lt;/small&amp;gt;&lt;br /&gt;
  make install&lt;br /&gt;
  make testprog&lt;br /&gt;
  ./testprog &amp;gt; testprog.lis&lt;br /&gt;
  diff testprog.lis testprog.out # There should not be any output &lt;br /&gt;
  cmp testprog.fit testprog.std  # There should not be any output&lt;br /&gt;
  sudo apt-get install happycoders-libsocket happycoders-libsocket-dev&lt;br /&gt;
  cd /usr/lib/&lt;br /&gt;
  sudo ln -s /usr/lib/happycoders/libsocket.so .&lt;br /&gt;
&lt;br /&gt;
* Proper linking (add in .bashrc file)&lt;br /&gt;
&lt;br /&gt;
 C_INCLUDE_PATH=/home/user/cfitsio/include&lt;br /&gt;
 LIBRARY_PATH=/home/user/cfitsio/lib&lt;br /&gt;
 export C_INCLUDE_PATH LIBRARY_PATH&lt;br /&gt;
&lt;br /&gt;
* Testing&lt;br /&gt;
 cd /home/user/cfitsio/&lt;br /&gt;
 make speed # measures the maximum throughput (in MB per second) for writing and reading FITS files with CFITSIO &lt;br /&gt;
 ./speed&lt;br /&gt;
 make listhead # lists all the header keywords in any FITS file&lt;br /&gt;
 ./listhead&lt;br /&gt;
 make fitscopy # copies any FITS file&lt;br /&gt;
 ./fitscopy&lt;br /&gt;
 make cookbook # a sample program that performs common read and write operations on a FITS file.&lt;br /&gt;
 ./cookbook&lt;br /&gt;
&lt;br /&gt;
* Compiling &lt;br /&gt;
** #include &amp;quot;fitsio.h&amp;quot; # Include in any .c program to use cfitsio library&lt;br /&gt;
  gcc -o iter_a iter_a.c -lcfitsio -lm &lt;br /&gt;
  ./iter_a&lt;br /&gt;
&lt;br /&gt;
The typical libraries that need to be added are &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lm&amp;lt;/font&amp;gt; (the math library) and &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lnsl&amp;lt;/font&amp;gt; and &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lsocket&amp;lt;/font&amp;gt; (needed only for FTP and HTTP file access).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[http://www.stsci.edu/resources/software_hardware/pyfits Pyfits] can be easily installed from the source:&lt;br /&gt;
 wget  http://www.stsci.edu/resources/software_hardware/pyfits/pyfits-2.3.1.tar.gz &lt;br /&gt;
 tar xvf pyfits-2.3.1.tar.gz&lt;br /&gt;
 cd pyfits-2.3.1/&lt;br /&gt;
 sudo  python setup.py install # To install in Python's site-packages directory (recommended)&lt;br /&gt;
OR &lt;br /&gt;
 sudo python setup.py install --prefix=&amp;quot;/destination/directory/&amp;quot;  # Wherever you want&lt;br /&gt;
&lt;br /&gt;
== [http://tdc-www.harvard.edu/software/wcstools/index.html WCSTools] ==&lt;br /&gt;
&lt;br /&gt;
WCSTools is a package of programs and a library of utility subroutines for setting and using the world coordinate systems (WCS) in the headers of the most common astronomical image formats, FITS and IRAF .imh, to relate image pixels to sky coordinates. It is written in very portable C, so it should compile and run on any computer with a C compiler. &lt;br /&gt;
&lt;br /&gt;
* WCS Tools installation&lt;br /&gt;
&lt;br /&gt;
Download the latest version of WCS tools, which is at the moment (August, 2010) [http://tdc-www.harvard.edu/software/wcstools/wcstools-3.8.1.tar.gz wcstools-3.8.1]. Unpack it:&lt;br /&gt;
 tar xvf wcstools-3.8.1.tar.gz&lt;br /&gt;
 cd wcstools-3.8.1&lt;br /&gt;
 export CC=gcc&lt;br /&gt;
 sudo make&lt;br /&gt;
 sudo mkdir -p /usr/wcstools/&lt;br /&gt;
 sudo mv bin /usr/wcstools &lt;br /&gt;
Open your .basrc file (in your home dir) and add the following lines:&lt;br /&gt;
 #WCSTools&lt;br /&gt;
 PATH=$PATH:/usr/wcstools/bin&lt;br /&gt;
 export PATH &lt;br /&gt;
Restart the xterm or type: &lt;br /&gt;
 source ~/.bashrc&lt;br /&gt;
&lt;br /&gt;
Now you have all wcstool commands available from the terminal:&lt;br /&gt;
 &lt;br /&gt;
 addpix   delwcs    getdate  imextract  imsmooth  keyhead  simpos   xy2sky&lt;br /&gt;
 bincat   edhead    getfits  imfill     imstack   nedpos   sky2xy&lt;br /&gt;
 char2sp  filename  gethead  imhead     imstar    newfits  skycoor&lt;br /&gt;
 conpix   fileroot  getpix   immatch    imwcs     remap    sp2char&lt;br /&gt;
 cphead   filext    gettab   imresize   isfits    scat     subpix&lt;br /&gt;
 crlf     fixpix    i2f      imrot      isnum     sethead  sumpix&lt;br /&gt;
 delhead  getcol    imcat    imsize     isrange   setpix   wcshead&lt;br /&gt;
&lt;br /&gt;
Enjoy!&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=Astro_links&amp;diff=124</id>
		<title>Astro links</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=Astro_links&amp;diff=124"/>
		<updated>2023-12-15T09:05:07Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* STSDAS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== [http://stsdas.stsci.edu/irafx STSDAS] ===&lt;br /&gt;
&lt;br /&gt;
In Ubuntu install IRAF using Synaptic. Than download STSDAS from http://stsdas.stsci.edu/irafx/stsdas.linux.tar.gz. Unpack, go to stsci_iraf_x dir and start ./install_helper. Export IRAF: export iraf='/home/user/.iraf/' from the terminal and start installer again. The following text will apear:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
reset   tables          = /home/user/stsci_iraf_x/tables/&lt;br /&gt;
task    tables.pkg      = tables$tables.cl&lt;br /&gt;
if (access(&amp;quot;tables$lib&amp;quot;)) reset helpdb= ( envget(&amp;quot;helpdb&amp;quot;) + &amp;quot;,tables$lib/helpdb.mip&amp;quot; )  &lt;br /&gt;
&lt;br /&gt;
reset   stsdas          = /home/user/stsci_iraf_x/stsdas/&lt;br /&gt;
task    stsdas.pkg      = stsdas$stsdas.cl&lt;br /&gt;
task    apropos         = stsdas$apropos.cl&lt;br /&gt;
if (access(&amp;quot;stsdas$lib&amp;quot;)) reset helpdb= ( envget(&amp;quot;helpdb&amp;quot;) + &amp;quot;,stsdas$lib/helpdb.mip&amp;quot; )  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the text, start xgterm from terminal, then irafcl in the xgterm and when iraf starts paste these few lines. Just check if the stsci_iraf_x folder is in the right place. Afterwards, you can normally use stsdas and tables.&lt;br /&gt;
&lt;br /&gt;
BETTER option, although it might not work is to the following:&lt;br /&gt;
&lt;br /&gt;
# edit your extern.pkg file:&lt;br /&gt;
sudo gedit /iraf/iraf/unix/hlib/extern.pkg&lt;br /&gt;
With the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
reset tables = /iraf/extern/tables/&lt;br /&gt;
task tables.pkg = tables$tables.cl&lt;br /&gt;
reset stsdas = /iraf/extern/stsdas/&lt;br /&gt;
task stsdas.pkg = stsdas$stsdas.cl&lt;br /&gt;
&lt;br /&gt;
reset helpdb = &amp;quot;lib$helpdb.mip\&lt;br /&gt;
,noao$lib/helpdb.mip\&lt;br /&gt;
,tables$lib/helpdb.mip\&lt;br /&gt;
,stsdas$lib/helpdb.mip\&lt;br /&gt;
&amp;quot;&lt;br /&gt;
keep&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# &amp;lt;font color=red&amp;gt;!!! Copy the missing text and uncomment existing but leave exactly the same spaces as in the original extern.pkg file - copy and paste blank fields (I cannot mimic that here) !!!&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [http://www.stsci.edu/resources/software_hardware/pyraf/current/download PYRAF] ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font color=red&amp;gt;''This pyraf goes with iraf, so first you have to install [http://wiki.ipb.ac.rs/index.php/IrafInstallation iraf].&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Download the latest pyraf release:&lt;br /&gt;
&lt;br /&gt;
wget http://stsdas.stsci.edu/download/pyraf/pyraf-1.9.tar.gz . # Check if this is still the latest release!!!&amp;lt;br&amp;gt;&lt;br /&gt;
tar xvf pyraf-1.9.tar.gz&amp;lt;br&amp;gt;&lt;br /&gt;
rm pyraf-1.9.tar.gz&amp;lt;br&amp;gt;&lt;br /&gt;
cd pytools&amp;lt;br&amp;gt;&lt;br /&gt;
sudo python setup.py install # This should go smoothly &amp;lt;br&amp;gt;&lt;br /&gt;
cd ../pyraf-1.9&amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install libx11-dev # Solved: Error &amp;quot;X11/X.h: No such file or directory&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
sudo apt-get install python-tk&amp;lt;br&amp;gt;&lt;br /&gt;
sudo python setup.py install &lt;br /&gt;
* In the case of error &amp;quot;Python.h missing&amp;quot; install the latest &amp;lt;font color=blue&amp;gt;python&amp;lt;/font&amp;gt; and &amp;lt;font color=blue&amp;gt;python-dev&amp;lt;/font&amp;gt; (python2.5 and python2.5-dev for Ubuntu 8.04) using synaptic&amp;lt;br&amp;gt;&lt;br /&gt;
* Check if you have &amp;lt;font color=blue&amp;gt;gcc&amp;lt;/font&amp;gt; and &amp;lt;font color=blue&amp;gt;gfortran&amp;lt;/font&amp;gt;, if not install:&amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install gcc&amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install gfortran&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Try to run again &amp;lt;font color=green&amp;gt; sudo python setup.py install &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* And run &amp;lt;font color=green&amp;gt; sudo python setup.py install &amp;lt;/font&amp;gt; again. If it reports that numpy is missing go to [http://sourceforge.net/projects/numpy/files/ SourceForge] and download source:&lt;br /&gt;
cd ../.&amp;lt;br&amp;gt;&lt;br /&gt;
wget http://sourceforge.net/projects/numpy/files/NumPy/1.4.1/numpy-1.4.1.tar.gz/download . # Check if this is the latest version&amp;lt;br&amp;gt;&lt;br /&gt;
tar xvf numpy-1.4.1.tar.gz&amp;lt;br&amp;gt;&lt;br /&gt;
cd numpy-1.4.1/&lt;br /&gt;
* Follow the instructions in INSTALL.txt, that are for Ubuntu 8.04. - 10.04:&lt;br /&gt;
sudo apt-get install libatlas-base-dev &amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install libatlas3gf-sse2 &amp;lt;br&amp;gt;&lt;br /&gt;
sudo python setup.py install &amp;lt;br&amp;gt;&lt;br /&gt;
* Go back to pyraf-1.9 directory and repeat&lt;br /&gt;
sudo python setup.py install &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should work!!!&lt;br /&gt;
&lt;br /&gt;
=== [http://heasarc.gsfc.nasa.gov/fitsio/ CFITSIO] ===&lt;br /&gt;
&lt;br /&gt;
CFITSIO is a library of C and Fortran subroutines for reading and writing data files in FITS. Installation under Linux (Ubuntu 8.04) with/without multithreading.&lt;br /&gt;
* Installation under Ubuntu 8.04&lt;br /&gt;
 cd /home/user/&lt;br /&gt;
 wget ftp://heasarc.gsfc.nasa.gov/software/fitsio/c/cfitsio3240.tar.gz . # Check for the latest version under [http://heasarc.gsfc.nasa.gov/fitsio/ Unix .tar file]&lt;br /&gt;
 tar zxvf cfitsio3240.tar.gz&lt;br /&gt;
 cd cfitsio/&lt;br /&gt;
  ./configure CC=gcc &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;--enable-reentrant&amp;lt;/font&amp;gt; # &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt; WITH MULTITHREAD&amp;lt;/font&amp;gt;&lt;br /&gt;
  make shared  # &amp;lt;small&amp;gt;builds a shared or dynamic version of the CFITSIO library saving the disk space, memory &amp;lt;/small&amp;gt; &lt;br /&gt;
  # &amp;lt;small&amp;gt; and enables easier maintenance since a new version of the shared library can be installed without relinking all the software that uses it &amp;lt;/small&amp;gt;&lt;br /&gt;
  make install&lt;br /&gt;
  make testprog&lt;br /&gt;
  ./testprog &amp;gt; testprog.lis&lt;br /&gt;
  diff testprog.lis testprog.out # There should not be any output &lt;br /&gt;
  cmp testprog.fit testprog.std  # There should not be any output&lt;br /&gt;
  sudo apt-get install happycoders-libsocket happycoders-libsocket-dev&lt;br /&gt;
  cd /usr/lib/&lt;br /&gt;
  sudo ln -s /usr/lib/happycoders/libsocket.so .&lt;br /&gt;
&lt;br /&gt;
* Proper linking (add in .bashrc file)&lt;br /&gt;
&lt;br /&gt;
 C_INCLUDE_PATH=/home/user/cfitsio/include&lt;br /&gt;
 LIBRARY_PATH=/home/user/cfitsio/lib&lt;br /&gt;
 export C_INCLUDE_PATH LIBRARY_PATH&lt;br /&gt;
&lt;br /&gt;
* Testing&lt;br /&gt;
 cd /home/user/cfitsio/&lt;br /&gt;
 make speed # measures the maximum throughput (in MB per second) for writing and reading FITS files with CFITSIO &lt;br /&gt;
 ./speed&lt;br /&gt;
 make listhead # lists all the header keywords in any FITS file&lt;br /&gt;
 ./listhead&lt;br /&gt;
 make fitscopy # copies any FITS file&lt;br /&gt;
 ./fitscopy&lt;br /&gt;
 make cookbook # a sample program that performs common read and write operations on a FITS file.&lt;br /&gt;
 ./cookbook&lt;br /&gt;
&lt;br /&gt;
* Compiling &lt;br /&gt;
** #include &amp;quot;fitsio.h&amp;quot; # Include in any .c program to use cfitsio library&lt;br /&gt;
  gcc -o iter_a iter_a.c -lcfitsio -lm &lt;br /&gt;
  ./iter_a&lt;br /&gt;
&lt;br /&gt;
The typical libraries that need to be added are &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lm&amp;lt;/font&amp;gt; (the math library) and &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lnsl&amp;lt;/font&amp;gt; and &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lsocket&amp;lt;/font&amp;gt; (needed only for FTP and HTTP file access).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[http://www.stsci.edu/resources/software_hardware/pyfits Pyfits] can be easily installed from the source:&lt;br /&gt;
 wget  http://www.stsci.edu/resources/software_hardware/pyfits/pyfits-2.3.1.tar.gz &lt;br /&gt;
 tar xvf pyfits-2.3.1.tar.gz&lt;br /&gt;
 cd pyfits-2.3.1/&lt;br /&gt;
 sudo  python setup.py install # To install in Python's site-packages directory (recommended)&lt;br /&gt;
OR &lt;br /&gt;
 sudo python setup.py install --prefix=&amp;quot;/destination/directory/&amp;quot;  # Wherever you want&lt;br /&gt;
&lt;br /&gt;
== [http://tdc-www.harvard.edu/software/wcstools/index.html WCSTools] ==&lt;br /&gt;
&lt;br /&gt;
WCSTools is a package of programs and a library of utility subroutines for setting and using the world coordinate systems (WCS) in the headers of the most common astronomical image formats, FITS and IRAF .imh, to relate image pixels to sky coordinates. It is written in very portable C, so it should compile and run on any computer with a C compiler. &lt;br /&gt;
&lt;br /&gt;
* WCS Tools installation&lt;br /&gt;
&lt;br /&gt;
Download the latest version of WCS tools, which is at the moment (August, 2010) [http://tdc-www.harvard.edu/software/wcstools/wcstools-3.8.1.tar.gz wcstools-3.8.1]. Unpack it:&lt;br /&gt;
 tar xvf wcstools-3.8.1.tar.gz&lt;br /&gt;
 cd wcstools-3.8.1&lt;br /&gt;
 export CC=gcc&lt;br /&gt;
 sudo make&lt;br /&gt;
 sudo mkdir -p /usr/wcstools/&lt;br /&gt;
 sudo mv bin /usr/wcstools &lt;br /&gt;
Open your .basrc file (in your home dir) and add the following lines:&lt;br /&gt;
 #WCSTools&lt;br /&gt;
 PATH=$PATH:/usr/wcstools/bin&lt;br /&gt;
 export PATH &lt;br /&gt;
Restart the xterm or type: &lt;br /&gt;
 source ~/.bashrc&lt;br /&gt;
&lt;br /&gt;
Now you have all wcstool commands available from the terminal:&lt;br /&gt;
 &lt;br /&gt;
 addpix   delwcs    getdate  imextract  imsmooth  keyhead  simpos   xy2sky&lt;br /&gt;
 bincat   edhead    getfits  imfill     imstack   nedpos   sky2xy&lt;br /&gt;
 char2sp  filename  gethead  imhead     imstar    newfits  skycoor&lt;br /&gt;
 conpix   fileroot  getpix   immatch    imwcs     remap    sp2char&lt;br /&gt;
 cphead   filext    gettab   imresize   isfits    scat     subpix&lt;br /&gt;
 crlf     fixpix    i2f      imrot      isnum     sethead  sumpix&lt;br /&gt;
 delhead  getcol    imcat    imsize     isrange   setpix   wcshead&lt;br /&gt;
&lt;br /&gt;
Enjoy!&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=Astro_links&amp;diff=123</id>
		<title>Astro links</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=Astro_links&amp;diff=123"/>
		<updated>2023-12-15T09:04:11Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* STSDAS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== [http://stsdas.stsci.edu/irafx STSDAS] ===&lt;br /&gt;
&lt;br /&gt;
In Ubuntu install IRAF using Synaptic. Than download STSDAS from http://stsdas.stsci.edu/irafx/stsdas.linux.tar.gz. Unpack, go to stsci_iraf_x dir and start ./install_helper. Export IRAF: export iraf='/home/user/.iraf/' from the terminal and start installer again. The following text will apear:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
reset   tables          = /home/user/stsci_iraf_x/tables/&lt;br /&gt;
task    tables.pkg      = tables$tables.cl&lt;br /&gt;
if (access(&amp;quot;tables$lib&amp;quot;)) reset helpdb= ( envget(&amp;quot;helpdb&amp;quot;) + &amp;quot;,tables$lib/helpdb.mip&amp;quot; )  &lt;br /&gt;
&lt;br /&gt;
reset   stsdas          = /home/user/stsci_iraf_x/stsdas/&lt;br /&gt;
task    stsdas.pkg      = stsdas$stsdas.cl&lt;br /&gt;
task    apropos         = stsdas$apropos.cl&lt;br /&gt;
if (access(&amp;quot;stsdas$lib&amp;quot;)) reset helpdb= ( envget(&amp;quot;helpdb&amp;quot;) + &amp;quot;,stsdas$lib/helpdb.mip&amp;quot; )  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the text, start xgterm from terminal, then irafcl in the xgterm and when iraf starts paste these few lines. Just check if the stsci_iraf_x folder is in the right place. Afterwards, you can normally use stsdas and tables.&lt;br /&gt;
&lt;br /&gt;
BETTER option, although it might not work is to the following:&lt;br /&gt;
&amp;lt;pra&amp;gt;&lt;br /&gt;
# edit your extern.pkg file:&lt;br /&gt;
sudo gedit /iraf/iraf/unix/hlib/extern.pkg&lt;br /&gt;
With the following lines:&lt;br /&gt;
&lt;br /&gt;
reset tables = /iraf/extern/tables/&lt;br /&gt;
task tables.pkg = tables$tables.cl&lt;br /&gt;
reset stsdas = /iraf/extern/stsdas/&lt;br /&gt;
task stsdas.pkg = stsdas$stsdas.cl&lt;br /&gt;
&lt;br /&gt;
reset helpdb = &amp;quot;lib$helpdb.mip\&lt;br /&gt;
,noao$lib/helpdb.mip\&lt;br /&gt;
,tables$lib/helpdb.mip\&lt;br /&gt;
,stsdas$lib/helpdb.mip\&lt;br /&gt;
&amp;quot;&lt;br /&gt;
keep&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/par&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font color=red&amp;gt;!!! Copy the missing text and uncomment existing but leave exactly the same spaces as in the original extern.pkg file - copy and paste blank fields (I cannot mimic that here) !!!&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [http://www.stsci.edu/resources/software_hardware/pyraf/current/download PYRAF] ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font color=red&amp;gt;''This pyraf goes with iraf, so first you have to install [http://wiki.ipb.ac.rs/index.php/IrafInstallation iraf].&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Download the latest pyraf release:&lt;br /&gt;
&lt;br /&gt;
wget http://stsdas.stsci.edu/download/pyraf/pyraf-1.9.tar.gz . # Check if this is still the latest release!!!&amp;lt;br&amp;gt;&lt;br /&gt;
tar xvf pyraf-1.9.tar.gz&amp;lt;br&amp;gt;&lt;br /&gt;
rm pyraf-1.9.tar.gz&amp;lt;br&amp;gt;&lt;br /&gt;
cd pytools&amp;lt;br&amp;gt;&lt;br /&gt;
sudo python setup.py install # This should go smoothly &amp;lt;br&amp;gt;&lt;br /&gt;
cd ../pyraf-1.9&amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install libx11-dev # Solved: Error &amp;quot;X11/X.h: No such file or directory&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
sudo apt-get install python-tk&amp;lt;br&amp;gt;&lt;br /&gt;
sudo python setup.py install &lt;br /&gt;
* In the case of error &amp;quot;Python.h missing&amp;quot; install the latest &amp;lt;font color=blue&amp;gt;python&amp;lt;/font&amp;gt; and &amp;lt;font color=blue&amp;gt;python-dev&amp;lt;/font&amp;gt; (python2.5 and python2.5-dev for Ubuntu 8.04) using synaptic&amp;lt;br&amp;gt;&lt;br /&gt;
* Check if you have &amp;lt;font color=blue&amp;gt;gcc&amp;lt;/font&amp;gt; and &amp;lt;font color=blue&amp;gt;gfortran&amp;lt;/font&amp;gt;, if not install:&amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install gcc&amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install gfortran&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Try to run again &amp;lt;font color=green&amp;gt; sudo python setup.py install &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* And run &amp;lt;font color=green&amp;gt; sudo python setup.py install &amp;lt;/font&amp;gt; again. If it reports that numpy is missing go to [http://sourceforge.net/projects/numpy/files/ SourceForge] and download source:&lt;br /&gt;
cd ../.&amp;lt;br&amp;gt;&lt;br /&gt;
wget http://sourceforge.net/projects/numpy/files/NumPy/1.4.1/numpy-1.4.1.tar.gz/download . # Check if this is the latest version&amp;lt;br&amp;gt;&lt;br /&gt;
tar xvf numpy-1.4.1.tar.gz&amp;lt;br&amp;gt;&lt;br /&gt;
cd numpy-1.4.1/&lt;br /&gt;
* Follow the instructions in INSTALL.txt, that are for Ubuntu 8.04. - 10.04:&lt;br /&gt;
sudo apt-get install libatlas-base-dev &amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install libatlas3gf-sse2 &amp;lt;br&amp;gt;&lt;br /&gt;
sudo python setup.py install &amp;lt;br&amp;gt;&lt;br /&gt;
* Go back to pyraf-1.9 directory and repeat&lt;br /&gt;
sudo python setup.py install &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should work!!!&lt;br /&gt;
&lt;br /&gt;
=== [http://heasarc.gsfc.nasa.gov/fitsio/ CFITSIO] ===&lt;br /&gt;
&lt;br /&gt;
CFITSIO is a library of C and Fortran subroutines for reading and writing data files in FITS. Installation under Linux (Ubuntu 8.04) with/without multithreading.&lt;br /&gt;
* Installation under Ubuntu 8.04&lt;br /&gt;
 cd /home/user/&lt;br /&gt;
 wget ftp://heasarc.gsfc.nasa.gov/software/fitsio/c/cfitsio3240.tar.gz . # Check for the latest version under [http://heasarc.gsfc.nasa.gov/fitsio/ Unix .tar file]&lt;br /&gt;
 tar zxvf cfitsio3240.tar.gz&lt;br /&gt;
 cd cfitsio/&lt;br /&gt;
  ./configure CC=gcc &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;--enable-reentrant&amp;lt;/font&amp;gt; # &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt; WITH MULTITHREAD&amp;lt;/font&amp;gt;&lt;br /&gt;
  make shared  # &amp;lt;small&amp;gt;builds a shared or dynamic version of the CFITSIO library saving the disk space, memory &amp;lt;/small&amp;gt; &lt;br /&gt;
  # &amp;lt;small&amp;gt; and enables easier maintenance since a new version of the shared library can be installed without relinking all the software that uses it &amp;lt;/small&amp;gt;&lt;br /&gt;
  make install&lt;br /&gt;
  make testprog&lt;br /&gt;
  ./testprog &amp;gt; testprog.lis&lt;br /&gt;
  diff testprog.lis testprog.out # There should not be any output &lt;br /&gt;
  cmp testprog.fit testprog.std  # There should not be any output&lt;br /&gt;
  sudo apt-get install happycoders-libsocket happycoders-libsocket-dev&lt;br /&gt;
  cd /usr/lib/&lt;br /&gt;
  sudo ln -s /usr/lib/happycoders/libsocket.so .&lt;br /&gt;
&lt;br /&gt;
* Proper linking (add in .bashrc file)&lt;br /&gt;
&lt;br /&gt;
 C_INCLUDE_PATH=/home/user/cfitsio/include&lt;br /&gt;
 LIBRARY_PATH=/home/user/cfitsio/lib&lt;br /&gt;
 export C_INCLUDE_PATH LIBRARY_PATH&lt;br /&gt;
&lt;br /&gt;
* Testing&lt;br /&gt;
 cd /home/user/cfitsio/&lt;br /&gt;
 make speed # measures the maximum throughput (in MB per second) for writing and reading FITS files with CFITSIO &lt;br /&gt;
 ./speed&lt;br /&gt;
 make listhead # lists all the header keywords in any FITS file&lt;br /&gt;
 ./listhead&lt;br /&gt;
 make fitscopy # copies any FITS file&lt;br /&gt;
 ./fitscopy&lt;br /&gt;
 make cookbook # a sample program that performs common read and write operations on a FITS file.&lt;br /&gt;
 ./cookbook&lt;br /&gt;
&lt;br /&gt;
* Compiling &lt;br /&gt;
** #include &amp;quot;fitsio.h&amp;quot; # Include in any .c program to use cfitsio library&lt;br /&gt;
  gcc -o iter_a iter_a.c -lcfitsio -lm &lt;br /&gt;
  ./iter_a&lt;br /&gt;
&lt;br /&gt;
The typical libraries that need to be added are &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lm&amp;lt;/font&amp;gt; (the math library) and &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lnsl&amp;lt;/font&amp;gt; and &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lsocket&amp;lt;/font&amp;gt; (needed only for FTP and HTTP file access).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[http://www.stsci.edu/resources/software_hardware/pyfits Pyfits] can be easily installed from the source:&lt;br /&gt;
 wget  http://www.stsci.edu/resources/software_hardware/pyfits/pyfits-2.3.1.tar.gz &lt;br /&gt;
 tar xvf pyfits-2.3.1.tar.gz&lt;br /&gt;
 cd pyfits-2.3.1/&lt;br /&gt;
 sudo  python setup.py install # To install in Python's site-packages directory (recommended)&lt;br /&gt;
OR &lt;br /&gt;
 sudo python setup.py install --prefix=&amp;quot;/destination/directory/&amp;quot;  # Wherever you want&lt;br /&gt;
&lt;br /&gt;
== [http://tdc-www.harvard.edu/software/wcstools/index.html WCSTools] ==&lt;br /&gt;
&lt;br /&gt;
WCSTools is a package of programs and a library of utility subroutines for setting and using the world coordinate systems (WCS) in the headers of the most common astronomical image formats, FITS and IRAF .imh, to relate image pixels to sky coordinates. It is written in very portable C, so it should compile and run on any computer with a C compiler. &lt;br /&gt;
&lt;br /&gt;
* WCS Tools installation&lt;br /&gt;
&lt;br /&gt;
Download the latest version of WCS tools, which is at the moment (August, 2010) [http://tdc-www.harvard.edu/software/wcstools/wcstools-3.8.1.tar.gz wcstools-3.8.1]. Unpack it:&lt;br /&gt;
 tar xvf wcstools-3.8.1.tar.gz&lt;br /&gt;
 cd wcstools-3.8.1&lt;br /&gt;
 export CC=gcc&lt;br /&gt;
 sudo make&lt;br /&gt;
 sudo mkdir -p /usr/wcstools/&lt;br /&gt;
 sudo mv bin /usr/wcstools &lt;br /&gt;
Open your .basrc file (in your home dir) and add the following lines:&lt;br /&gt;
 #WCSTools&lt;br /&gt;
 PATH=$PATH:/usr/wcstools/bin&lt;br /&gt;
 export PATH &lt;br /&gt;
Restart the xterm or type: &lt;br /&gt;
 source ~/.bashrc&lt;br /&gt;
&lt;br /&gt;
Now you have all wcstool commands available from the terminal:&lt;br /&gt;
 &lt;br /&gt;
 addpix   delwcs    getdate  imextract  imsmooth  keyhead  simpos   xy2sky&lt;br /&gt;
 bincat   edhead    getfits  imfill     imstack   nedpos   sky2xy&lt;br /&gt;
 char2sp  filename  gethead  imhead     imstar    newfits  skycoor&lt;br /&gt;
 conpix   fileroot  getpix   immatch    imwcs     remap    sp2char&lt;br /&gt;
 cphead   filext    gettab   imresize   isfits    scat     subpix&lt;br /&gt;
 crlf     fixpix    i2f      imrot      isnum     sethead  sumpix&lt;br /&gt;
 delhead  getcol    imcat    imsize     isrange   setpix   wcshead&lt;br /&gt;
&lt;br /&gt;
Enjoy!&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=Astro_links&amp;diff=122</id>
		<title>Astro links</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=Astro_links&amp;diff=122"/>
		<updated>2023-12-15T09:03:40Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* STSDAS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== [http://stsdas.stsci.edu/irafx STSDAS] ===&lt;br /&gt;
&lt;br /&gt;
In Ubuntu install IRAF using Synaptic. Than download STSDAS from http://stsdas.stsci.edu/irafx/stsdas.linux.tar.gz. Unpack, go to stsci_iraf_x dir and start ./install_helper. Export IRAF: export iraf='/home/user/.iraf/' from the terminal and start installer again. The following text will apear:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
reset   tables          = /home/user/stsci_iraf_x/tables/&lt;br /&gt;
task    tables.pkg      = tables$tables.cl&lt;br /&gt;
if (access(&amp;quot;tables$lib&amp;quot;)) reset helpdb= ( envget(&amp;quot;helpdb&amp;quot;) + &amp;quot;,tables$lib/helpdb.mip&amp;quot; )  &lt;br /&gt;
&lt;br /&gt;
reset   stsdas          = /home/user/stsci_iraf_x/stsdas/&lt;br /&gt;
task    stsdas.pkg      = stsdas$stsdas.cl&lt;br /&gt;
task    apropos         = stsdas$apropos.cl&lt;br /&gt;
if (access(&amp;quot;stsdas$lib&amp;quot;)) reset helpdb= ( envget(&amp;quot;helpdb&amp;quot;) + &amp;quot;,stsdas$lib/helpdb.mip&amp;quot; )  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the text, start xgterm from terminal, then irafcl in the xgterm and when iraf starts paste these few lines. Just check if the stsci_iraf_x folder is in the right place. Afterwards, you can normally use stsdas and tables.&lt;br /&gt;
&lt;br /&gt;
BETTER option, although it might not work is to the following:&lt;br /&gt;
&amp;lt;pra&amp;gt;&lt;br /&gt;
# edit your extern.pkg file:&lt;br /&gt;
sudo gedit /iraf/iraf/unix/hlib/extern.pkg&lt;br /&gt;
With the following lines:&lt;br /&gt;
reset tables = /iraf/extern/tables/&lt;br /&gt;
task tables.pkg = tables$tables.cl&lt;br /&gt;
reset stsdas = /iraf/extern/stsdas/&lt;br /&gt;
task stsdas.pkg = stsdas$stsdas.cl&lt;br /&gt;
&lt;br /&gt;
reset helpdb = &amp;quot;lib$helpdb.mip\&lt;br /&gt;
,noao$lib/helpdb.mip\&lt;br /&gt;
,tables$lib/helpdb.mip\&lt;br /&gt;
,stsdas$lib/helpdb.mip\&lt;br /&gt;
&amp;quot;&lt;br /&gt;
keep&lt;br /&gt;
&amp;lt;/par&amp;gt;&lt;br /&gt;
&amp;lt;font color=red&amp;gt;!!! Copy the missing text and uncomment existing but leave exactly the same spaces as in the original extern.pkg file - copy and paste blank fields (I cannot mimic that here) !!!&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [http://www.stsci.edu/resources/software_hardware/pyraf/current/download PYRAF] ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font color=red&amp;gt;''This pyraf goes with iraf, so first you have to install [http://wiki.ipb.ac.rs/index.php/IrafInstallation iraf].&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Download the latest pyraf release:&lt;br /&gt;
&lt;br /&gt;
wget http://stsdas.stsci.edu/download/pyraf/pyraf-1.9.tar.gz . # Check if this is still the latest release!!!&amp;lt;br&amp;gt;&lt;br /&gt;
tar xvf pyraf-1.9.tar.gz&amp;lt;br&amp;gt;&lt;br /&gt;
rm pyraf-1.9.tar.gz&amp;lt;br&amp;gt;&lt;br /&gt;
cd pytools&amp;lt;br&amp;gt;&lt;br /&gt;
sudo python setup.py install # This should go smoothly &amp;lt;br&amp;gt;&lt;br /&gt;
cd ../pyraf-1.9&amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install libx11-dev # Solved: Error &amp;quot;X11/X.h: No such file or directory&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
sudo apt-get install python-tk&amp;lt;br&amp;gt;&lt;br /&gt;
sudo python setup.py install &lt;br /&gt;
* In the case of error &amp;quot;Python.h missing&amp;quot; install the latest &amp;lt;font color=blue&amp;gt;python&amp;lt;/font&amp;gt; and &amp;lt;font color=blue&amp;gt;python-dev&amp;lt;/font&amp;gt; (python2.5 and python2.5-dev for Ubuntu 8.04) using synaptic&amp;lt;br&amp;gt;&lt;br /&gt;
* Check if you have &amp;lt;font color=blue&amp;gt;gcc&amp;lt;/font&amp;gt; and &amp;lt;font color=blue&amp;gt;gfortran&amp;lt;/font&amp;gt;, if not install:&amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install gcc&amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install gfortran&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Try to run again &amp;lt;font color=green&amp;gt; sudo python setup.py install &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* And run &amp;lt;font color=green&amp;gt; sudo python setup.py install &amp;lt;/font&amp;gt; again. If it reports that numpy is missing go to [http://sourceforge.net/projects/numpy/files/ SourceForge] and download source:&lt;br /&gt;
cd ../.&amp;lt;br&amp;gt;&lt;br /&gt;
wget http://sourceforge.net/projects/numpy/files/NumPy/1.4.1/numpy-1.4.1.tar.gz/download . # Check if this is the latest version&amp;lt;br&amp;gt;&lt;br /&gt;
tar xvf numpy-1.4.1.tar.gz&amp;lt;br&amp;gt;&lt;br /&gt;
cd numpy-1.4.1/&lt;br /&gt;
* Follow the instructions in INSTALL.txt, that are for Ubuntu 8.04. - 10.04:&lt;br /&gt;
sudo apt-get install libatlas-base-dev &amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install libatlas3gf-sse2 &amp;lt;br&amp;gt;&lt;br /&gt;
sudo python setup.py install &amp;lt;br&amp;gt;&lt;br /&gt;
* Go back to pyraf-1.9 directory and repeat&lt;br /&gt;
sudo python setup.py install &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should work!!!&lt;br /&gt;
&lt;br /&gt;
=== [http://heasarc.gsfc.nasa.gov/fitsio/ CFITSIO] ===&lt;br /&gt;
&lt;br /&gt;
CFITSIO is a library of C and Fortran subroutines for reading and writing data files in FITS. Installation under Linux (Ubuntu 8.04) with/without multithreading.&lt;br /&gt;
* Installation under Ubuntu 8.04&lt;br /&gt;
 cd /home/user/&lt;br /&gt;
 wget ftp://heasarc.gsfc.nasa.gov/software/fitsio/c/cfitsio3240.tar.gz . # Check for the latest version under [http://heasarc.gsfc.nasa.gov/fitsio/ Unix .tar file]&lt;br /&gt;
 tar zxvf cfitsio3240.tar.gz&lt;br /&gt;
 cd cfitsio/&lt;br /&gt;
  ./configure CC=gcc &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;--enable-reentrant&amp;lt;/font&amp;gt; # &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt; WITH MULTITHREAD&amp;lt;/font&amp;gt;&lt;br /&gt;
  make shared  # &amp;lt;small&amp;gt;builds a shared or dynamic version of the CFITSIO library saving the disk space, memory &amp;lt;/small&amp;gt; &lt;br /&gt;
  # &amp;lt;small&amp;gt; and enables easier maintenance since a new version of the shared library can be installed without relinking all the software that uses it &amp;lt;/small&amp;gt;&lt;br /&gt;
  make install&lt;br /&gt;
  make testprog&lt;br /&gt;
  ./testprog &amp;gt; testprog.lis&lt;br /&gt;
  diff testprog.lis testprog.out # There should not be any output &lt;br /&gt;
  cmp testprog.fit testprog.std  # There should not be any output&lt;br /&gt;
  sudo apt-get install happycoders-libsocket happycoders-libsocket-dev&lt;br /&gt;
  cd /usr/lib/&lt;br /&gt;
  sudo ln -s /usr/lib/happycoders/libsocket.so .&lt;br /&gt;
&lt;br /&gt;
* Proper linking (add in .bashrc file)&lt;br /&gt;
&lt;br /&gt;
 C_INCLUDE_PATH=/home/user/cfitsio/include&lt;br /&gt;
 LIBRARY_PATH=/home/user/cfitsio/lib&lt;br /&gt;
 export C_INCLUDE_PATH LIBRARY_PATH&lt;br /&gt;
&lt;br /&gt;
* Testing&lt;br /&gt;
 cd /home/user/cfitsio/&lt;br /&gt;
 make speed # measures the maximum throughput (in MB per second) for writing and reading FITS files with CFITSIO &lt;br /&gt;
 ./speed&lt;br /&gt;
 make listhead # lists all the header keywords in any FITS file&lt;br /&gt;
 ./listhead&lt;br /&gt;
 make fitscopy # copies any FITS file&lt;br /&gt;
 ./fitscopy&lt;br /&gt;
 make cookbook # a sample program that performs common read and write operations on a FITS file.&lt;br /&gt;
 ./cookbook&lt;br /&gt;
&lt;br /&gt;
* Compiling &lt;br /&gt;
** #include &amp;quot;fitsio.h&amp;quot; # Include in any .c program to use cfitsio library&lt;br /&gt;
  gcc -o iter_a iter_a.c -lcfitsio -lm &lt;br /&gt;
  ./iter_a&lt;br /&gt;
&lt;br /&gt;
The typical libraries that need to be added are &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lm&amp;lt;/font&amp;gt; (the math library) and &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lnsl&amp;lt;/font&amp;gt; and &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lsocket&amp;lt;/font&amp;gt; (needed only for FTP and HTTP file access).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[http://www.stsci.edu/resources/software_hardware/pyfits Pyfits] can be easily installed from the source:&lt;br /&gt;
 wget  http://www.stsci.edu/resources/software_hardware/pyfits/pyfits-2.3.1.tar.gz &lt;br /&gt;
 tar xvf pyfits-2.3.1.tar.gz&lt;br /&gt;
 cd pyfits-2.3.1/&lt;br /&gt;
 sudo  python setup.py install # To install in Python's site-packages directory (recommended)&lt;br /&gt;
OR &lt;br /&gt;
 sudo python setup.py install --prefix=&amp;quot;/destination/directory/&amp;quot;  # Wherever you want&lt;br /&gt;
&lt;br /&gt;
== [http://tdc-www.harvard.edu/software/wcstools/index.html WCSTools] ==&lt;br /&gt;
&lt;br /&gt;
WCSTools is a package of programs and a library of utility subroutines for setting and using the world coordinate systems (WCS) in the headers of the most common astronomical image formats, FITS and IRAF .imh, to relate image pixels to sky coordinates. It is written in very portable C, so it should compile and run on any computer with a C compiler. &lt;br /&gt;
&lt;br /&gt;
* WCS Tools installation&lt;br /&gt;
&lt;br /&gt;
Download the latest version of WCS tools, which is at the moment (August, 2010) [http://tdc-www.harvard.edu/software/wcstools/wcstools-3.8.1.tar.gz wcstools-3.8.1]. Unpack it:&lt;br /&gt;
 tar xvf wcstools-3.8.1.tar.gz&lt;br /&gt;
 cd wcstools-3.8.1&lt;br /&gt;
 export CC=gcc&lt;br /&gt;
 sudo make&lt;br /&gt;
 sudo mkdir -p /usr/wcstools/&lt;br /&gt;
 sudo mv bin /usr/wcstools &lt;br /&gt;
Open your .basrc file (in your home dir) and add the following lines:&lt;br /&gt;
 #WCSTools&lt;br /&gt;
 PATH=$PATH:/usr/wcstools/bin&lt;br /&gt;
 export PATH &lt;br /&gt;
Restart the xterm or type: &lt;br /&gt;
 source ~/.bashrc&lt;br /&gt;
&lt;br /&gt;
Now you have all wcstool commands available from the terminal:&lt;br /&gt;
 &lt;br /&gt;
 addpix   delwcs    getdate  imextract  imsmooth  keyhead  simpos   xy2sky&lt;br /&gt;
 bincat   edhead    getfits  imfill     imstack   nedpos   sky2xy&lt;br /&gt;
 char2sp  filename  gethead  imhead     imstar    newfits  skycoor&lt;br /&gt;
 conpix   fileroot  getpix   immatch    imwcs     remap    sp2char&lt;br /&gt;
 cphead   filext    gettab   imresize   isfits    scat     subpix&lt;br /&gt;
 crlf     fixpix    i2f      imrot      isnum     sethead  sumpix&lt;br /&gt;
 delhead  getcol    imcat    imsize     isrange   setpix   wcshead&lt;br /&gt;
&lt;br /&gt;
Enjoy!&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=Astro_links&amp;diff=121</id>
		<title>Astro links</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=Astro_links&amp;diff=121"/>
		<updated>2023-12-05T12:45:06Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* STSDAS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== [http://stsdas.stsci.edu/irafx STSDAS] ===&lt;br /&gt;
&lt;br /&gt;
In Ubuntu install IRAF using Synaptic. Than download STSDAS from http://stsdas.stsci.edu/irafx/stsdas.linux.tar.gz. Unpack, go to stsci_iraf_x dir and start ./install_helper. Export IRAF: export iraf='/home/user/.iraf/' from the terminal and start installer again. The following text will apear:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
reset   tables          = /home/user/stsci_iraf_x/tables/&lt;br /&gt;
task    tables.pkg      = tables$tables.cl&lt;br /&gt;
if (access(&amp;quot;tables$lib&amp;quot;)) reset helpdb= ( envget(&amp;quot;helpdb&amp;quot;) + &amp;quot;,tables$lib/helpdb.mip&amp;quot; )  &lt;br /&gt;
&lt;br /&gt;
reset   stsdas          = /home/user/stsci_iraf_x/stsdas/&lt;br /&gt;
task    stsdas.pkg      = stsdas$stsdas.cl&lt;br /&gt;
task    apropos         = stsdas$apropos.cl&lt;br /&gt;
if (access(&amp;quot;stsdas$lib&amp;quot;)) reset helpdb= ( envget(&amp;quot;helpdb&amp;quot;) + &amp;quot;,stsdas$lib/helpdb.mip&amp;quot; )  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the text, start xgterm from terminal, then irafcl in the xgterm and when iraf starts paste these few lines. Just check if the stsci_iraf_x folder is in the right place. Afterwards, you can normally use stsdas and tables.&lt;br /&gt;
&lt;br /&gt;
=== [http://www.stsci.edu/resources/software_hardware/pyraf/current/download PYRAF] ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font color=red&amp;gt;''This pyraf goes with iraf, so first you have to install [http://wiki.ipb.ac.rs/index.php/IrafInstallation iraf].&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Download the latest pyraf release:&lt;br /&gt;
&lt;br /&gt;
wget http://stsdas.stsci.edu/download/pyraf/pyraf-1.9.tar.gz . # Check if this is still the latest release!!!&amp;lt;br&amp;gt;&lt;br /&gt;
tar xvf pyraf-1.9.tar.gz&amp;lt;br&amp;gt;&lt;br /&gt;
rm pyraf-1.9.tar.gz&amp;lt;br&amp;gt;&lt;br /&gt;
cd pytools&amp;lt;br&amp;gt;&lt;br /&gt;
sudo python setup.py install # This should go smoothly &amp;lt;br&amp;gt;&lt;br /&gt;
cd ../pyraf-1.9&amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install libx11-dev # Solved: Error &amp;quot;X11/X.h: No such file or directory&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
sudo apt-get install python-tk&amp;lt;br&amp;gt;&lt;br /&gt;
sudo python setup.py install &lt;br /&gt;
* In the case of error &amp;quot;Python.h missing&amp;quot; install the latest &amp;lt;font color=blue&amp;gt;python&amp;lt;/font&amp;gt; and &amp;lt;font color=blue&amp;gt;python-dev&amp;lt;/font&amp;gt; (python2.5 and python2.5-dev for Ubuntu 8.04) using synaptic&amp;lt;br&amp;gt;&lt;br /&gt;
* Check if you have &amp;lt;font color=blue&amp;gt;gcc&amp;lt;/font&amp;gt; and &amp;lt;font color=blue&amp;gt;gfortran&amp;lt;/font&amp;gt;, if not install:&amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install gcc&amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install gfortran&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Try to run again &amp;lt;font color=green&amp;gt; sudo python setup.py install &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* And run &amp;lt;font color=green&amp;gt; sudo python setup.py install &amp;lt;/font&amp;gt; again. If it reports that numpy is missing go to [http://sourceforge.net/projects/numpy/files/ SourceForge] and download source:&lt;br /&gt;
cd ../.&amp;lt;br&amp;gt;&lt;br /&gt;
wget http://sourceforge.net/projects/numpy/files/NumPy/1.4.1/numpy-1.4.1.tar.gz/download . # Check if this is the latest version&amp;lt;br&amp;gt;&lt;br /&gt;
tar xvf numpy-1.4.1.tar.gz&amp;lt;br&amp;gt;&lt;br /&gt;
cd numpy-1.4.1/&lt;br /&gt;
* Follow the instructions in INSTALL.txt, that are for Ubuntu 8.04. - 10.04:&lt;br /&gt;
sudo apt-get install libatlas-base-dev &amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install libatlas3gf-sse2 &amp;lt;br&amp;gt;&lt;br /&gt;
sudo python setup.py install &amp;lt;br&amp;gt;&lt;br /&gt;
* Go back to pyraf-1.9 directory and repeat&lt;br /&gt;
sudo python setup.py install &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should work!!!&lt;br /&gt;
&lt;br /&gt;
=== [http://heasarc.gsfc.nasa.gov/fitsio/ CFITSIO] ===&lt;br /&gt;
&lt;br /&gt;
CFITSIO is a library of C and Fortran subroutines for reading and writing data files in FITS. Installation under Linux (Ubuntu 8.04) with/without multithreading.&lt;br /&gt;
* Installation under Ubuntu 8.04&lt;br /&gt;
 cd /home/user/&lt;br /&gt;
 wget ftp://heasarc.gsfc.nasa.gov/software/fitsio/c/cfitsio3240.tar.gz . # Check for the latest version under [http://heasarc.gsfc.nasa.gov/fitsio/ Unix .tar file]&lt;br /&gt;
 tar zxvf cfitsio3240.tar.gz&lt;br /&gt;
 cd cfitsio/&lt;br /&gt;
  ./configure CC=gcc &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;--enable-reentrant&amp;lt;/font&amp;gt; # &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt; WITH MULTITHREAD&amp;lt;/font&amp;gt;&lt;br /&gt;
  make shared  # &amp;lt;small&amp;gt;builds a shared or dynamic version of the CFITSIO library saving the disk space, memory &amp;lt;/small&amp;gt; &lt;br /&gt;
  # &amp;lt;small&amp;gt; and enables easier maintenance since a new version of the shared library can be installed without relinking all the software that uses it &amp;lt;/small&amp;gt;&lt;br /&gt;
  make install&lt;br /&gt;
  make testprog&lt;br /&gt;
  ./testprog &amp;gt; testprog.lis&lt;br /&gt;
  diff testprog.lis testprog.out # There should not be any output &lt;br /&gt;
  cmp testprog.fit testprog.std  # There should not be any output&lt;br /&gt;
  sudo apt-get install happycoders-libsocket happycoders-libsocket-dev&lt;br /&gt;
  cd /usr/lib/&lt;br /&gt;
  sudo ln -s /usr/lib/happycoders/libsocket.so .&lt;br /&gt;
&lt;br /&gt;
* Proper linking (add in .bashrc file)&lt;br /&gt;
&lt;br /&gt;
 C_INCLUDE_PATH=/home/user/cfitsio/include&lt;br /&gt;
 LIBRARY_PATH=/home/user/cfitsio/lib&lt;br /&gt;
 export C_INCLUDE_PATH LIBRARY_PATH&lt;br /&gt;
&lt;br /&gt;
* Testing&lt;br /&gt;
 cd /home/user/cfitsio/&lt;br /&gt;
 make speed # measures the maximum throughput (in MB per second) for writing and reading FITS files with CFITSIO &lt;br /&gt;
 ./speed&lt;br /&gt;
 make listhead # lists all the header keywords in any FITS file&lt;br /&gt;
 ./listhead&lt;br /&gt;
 make fitscopy # copies any FITS file&lt;br /&gt;
 ./fitscopy&lt;br /&gt;
 make cookbook # a sample program that performs common read and write operations on a FITS file.&lt;br /&gt;
 ./cookbook&lt;br /&gt;
&lt;br /&gt;
* Compiling &lt;br /&gt;
** #include &amp;quot;fitsio.h&amp;quot; # Include in any .c program to use cfitsio library&lt;br /&gt;
  gcc -o iter_a iter_a.c -lcfitsio -lm &lt;br /&gt;
  ./iter_a&lt;br /&gt;
&lt;br /&gt;
The typical libraries that need to be added are &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lm&amp;lt;/font&amp;gt; (the math library) and &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lnsl&amp;lt;/font&amp;gt; and &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lsocket&amp;lt;/font&amp;gt; (needed only for FTP and HTTP file access).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[http://www.stsci.edu/resources/software_hardware/pyfits Pyfits] can be easily installed from the source:&lt;br /&gt;
 wget  http://www.stsci.edu/resources/software_hardware/pyfits/pyfits-2.3.1.tar.gz &lt;br /&gt;
 tar xvf pyfits-2.3.1.tar.gz&lt;br /&gt;
 cd pyfits-2.3.1/&lt;br /&gt;
 sudo  python setup.py install # To install in Python's site-packages directory (recommended)&lt;br /&gt;
OR &lt;br /&gt;
 sudo python setup.py install --prefix=&amp;quot;/destination/directory/&amp;quot;  # Wherever you want&lt;br /&gt;
&lt;br /&gt;
== [http://tdc-www.harvard.edu/software/wcstools/index.html WCSTools] ==&lt;br /&gt;
&lt;br /&gt;
WCSTools is a package of programs and a library of utility subroutines for setting and using the world coordinate systems (WCS) in the headers of the most common astronomical image formats, FITS and IRAF .imh, to relate image pixels to sky coordinates. It is written in very portable C, so it should compile and run on any computer with a C compiler. &lt;br /&gt;
&lt;br /&gt;
* WCS Tools installation&lt;br /&gt;
&lt;br /&gt;
Download the latest version of WCS tools, which is at the moment (August, 2010) [http://tdc-www.harvard.edu/software/wcstools/wcstools-3.8.1.tar.gz wcstools-3.8.1]. Unpack it:&lt;br /&gt;
 tar xvf wcstools-3.8.1.tar.gz&lt;br /&gt;
 cd wcstools-3.8.1&lt;br /&gt;
 export CC=gcc&lt;br /&gt;
 sudo make&lt;br /&gt;
 sudo mkdir -p /usr/wcstools/&lt;br /&gt;
 sudo mv bin /usr/wcstools &lt;br /&gt;
Open your .basrc file (in your home dir) and add the following lines:&lt;br /&gt;
 #WCSTools&lt;br /&gt;
 PATH=$PATH:/usr/wcstools/bin&lt;br /&gt;
 export PATH &lt;br /&gt;
Restart the xterm or type: &lt;br /&gt;
 source ~/.bashrc&lt;br /&gt;
&lt;br /&gt;
Now you have all wcstool commands available from the terminal:&lt;br /&gt;
 &lt;br /&gt;
 addpix   delwcs    getdate  imextract  imsmooth  keyhead  simpos   xy2sky&lt;br /&gt;
 bincat   edhead    getfits  imfill     imstack   nedpos   sky2xy&lt;br /&gt;
 char2sp  filename  gethead  imhead     imstar    newfits  skycoor&lt;br /&gt;
 conpix   fileroot  getpix   immatch    imwcs     remap    sp2char&lt;br /&gt;
 cphead   filext    gettab   imresize   isfits    scat     subpix&lt;br /&gt;
 crlf     fixpix    i2f      imrot      isnum     sethead  sumpix&lt;br /&gt;
 delhead  getcol    imcat    imsize     isrange   setpix   wcshead&lt;br /&gt;
&lt;br /&gt;
Enjoy!&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=Astro_links&amp;diff=120</id>
		<title>Astro links</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=Astro_links&amp;diff=120"/>
		<updated>2023-12-05T12:44:04Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* STSDAS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== [http://stsdas.stsci.edu/irafx STSDAS] ===&lt;br /&gt;
&lt;br /&gt;
In Ubuntu install IRAF using Synaptic. Than download STSDAS from http://stsdas.stsci.edu/irafx/stsdas.linux.tar.gz. Unpack, go to stsci_iraf_x dir and start ./install_helper. Export IRAF: export iraf='/home/user/.iraf/' from the terminal and start installer again. The following text will apear:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
reset   tables          = /home/user/stsci_iraf_x/tables/&lt;br /&gt;
task    tables.pkg      = tables$tables.cl&lt;br /&gt;
if (access(&amp;quot;tables$lib&amp;quot;)) reset helpdb= ( envget(&amp;quot;helpdb&amp;quot;) + &amp;quot;,tables$lib/helpdb.mip&amp;quot; )  &lt;br /&gt;
&lt;br /&gt;
reset   stsdas          = /home/user/stsci_iraf_x/stsdas/&lt;br /&gt;
task    stsdas.pkg      = stsdas$stsdas.cl&lt;br /&gt;
task    apropos         = stsdas$apropos.cl&lt;br /&gt;
if (access(&amp;quot;stsdas$lib&amp;quot;)) reset helpdb= ( envget(&amp;quot;helpdb&amp;quot;) + &amp;quot;,stsdas$lib/helpdb.mip&amp;quot; )  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the text, start xgterm from terminal, then irafcl in the xgterm and when iraf starts paste these two lines. Just check if the stsci_iraf_x folder is in the right place. Afterwards, you can normally use stsdas and tables.&lt;br /&gt;
&lt;br /&gt;
=== [http://www.stsci.edu/resources/software_hardware/pyraf/current/download PYRAF] ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font color=red&amp;gt;''This pyraf goes with iraf, so first you have to install [http://wiki.ipb.ac.rs/index.php/IrafInstallation iraf].&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Download the latest pyraf release:&lt;br /&gt;
&lt;br /&gt;
wget http://stsdas.stsci.edu/download/pyraf/pyraf-1.9.tar.gz . # Check if this is still the latest release!!!&amp;lt;br&amp;gt;&lt;br /&gt;
tar xvf pyraf-1.9.tar.gz&amp;lt;br&amp;gt;&lt;br /&gt;
rm pyraf-1.9.tar.gz&amp;lt;br&amp;gt;&lt;br /&gt;
cd pytools&amp;lt;br&amp;gt;&lt;br /&gt;
sudo python setup.py install # This should go smoothly &amp;lt;br&amp;gt;&lt;br /&gt;
cd ../pyraf-1.9&amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install libx11-dev # Solved: Error &amp;quot;X11/X.h: No such file or directory&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
sudo apt-get install python-tk&amp;lt;br&amp;gt;&lt;br /&gt;
sudo python setup.py install &lt;br /&gt;
* In the case of error &amp;quot;Python.h missing&amp;quot; install the latest &amp;lt;font color=blue&amp;gt;python&amp;lt;/font&amp;gt; and &amp;lt;font color=blue&amp;gt;python-dev&amp;lt;/font&amp;gt; (python2.5 and python2.5-dev for Ubuntu 8.04) using synaptic&amp;lt;br&amp;gt;&lt;br /&gt;
* Check if you have &amp;lt;font color=blue&amp;gt;gcc&amp;lt;/font&amp;gt; and &amp;lt;font color=blue&amp;gt;gfortran&amp;lt;/font&amp;gt;, if not install:&amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install gcc&amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install gfortran&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Try to run again &amp;lt;font color=green&amp;gt; sudo python setup.py install &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* And run &amp;lt;font color=green&amp;gt; sudo python setup.py install &amp;lt;/font&amp;gt; again. If it reports that numpy is missing go to [http://sourceforge.net/projects/numpy/files/ SourceForge] and download source:&lt;br /&gt;
cd ../.&amp;lt;br&amp;gt;&lt;br /&gt;
wget http://sourceforge.net/projects/numpy/files/NumPy/1.4.1/numpy-1.4.1.tar.gz/download . # Check if this is the latest version&amp;lt;br&amp;gt;&lt;br /&gt;
tar xvf numpy-1.4.1.tar.gz&amp;lt;br&amp;gt;&lt;br /&gt;
cd numpy-1.4.1/&lt;br /&gt;
* Follow the instructions in INSTALL.txt, that are for Ubuntu 8.04. - 10.04:&lt;br /&gt;
sudo apt-get install libatlas-base-dev &amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install libatlas3gf-sse2 &amp;lt;br&amp;gt;&lt;br /&gt;
sudo python setup.py install &amp;lt;br&amp;gt;&lt;br /&gt;
* Go back to pyraf-1.9 directory and repeat&lt;br /&gt;
sudo python setup.py install &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should work!!!&lt;br /&gt;
&lt;br /&gt;
=== [http://heasarc.gsfc.nasa.gov/fitsio/ CFITSIO] ===&lt;br /&gt;
&lt;br /&gt;
CFITSIO is a library of C and Fortran subroutines for reading and writing data files in FITS. Installation under Linux (Ubuntu 8.04) with/without multithreading.&lt;br /&gt;
* Installation under Ubuntu 8.04&lt;br /&gt;
 cd /home/user/&lt;br /&gt;
 wget ftp://heasarc.gsfc.nasa.gov/software/fitsio/c/cfitsio3240.tar.gz . # Check for the latest version under [http://heasarc.gsfc.nasa.gov/fitsio/ Unix .tar file]&lt;br /&gt;
 tar zxvf cfitsio3240.tar.gz&lt;br /&gt;
 cd cfitsio/&lt;br /&gt;
  ./configure CC=gcc &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;--enable-reentrant&amp;lt;/font&amp;gt; # &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt; WITH MULTITHREAD&amp;lt;/font&amp;gt;&lt;br /&gt;
  make shared  # &amp;lt;small&amp;gt;builds a shared or dynamic version of the CFITSIO library saving the disk space, memory &amp;lt;/small&amp;gt; &lt;br /&gt;
  # &amp;lt;small&amp;gt; and enables easier maintenance since a new version of the shared library can be installed without relinking all the software that uses it &amp;lt;/small&amp;gt;&lt;br /&gt;
  make install&lt;br /&gt;
  make testprog&lt;br /&gt;
  ./testprog &amp;gt; testprog.lis&lt;br /&gt;
  diff testprog.lis testprog.out # There should not be any output &lt;br /&gt;
  cmp testprog.fit testprog.std  # There should not be any output&lt;br /&gt;
  sudo apt-get install happycoders-libsocket happycoders-libsocket-dev&lt;br /&gt;
  cd /usr/lib/&lt;br /&gt;
  sudo ln -s /usr/lib/happycoders/libsocket.so .&lt;br /&gt;
&lt;br /&gt;
* Proper linking (add in .bashrc file)&lt;br /&gt;
&lt;br /&gt;
 C_INCLUDE_PATH=/home/user/cfitsio/include&lt;br /&gt;
 LIBRARY_PATH=/home/user/cfitsio/lib&lt;br /&gt;
 export C_INCLUDE_PATH LIBRARY_PATH&lt;br /&gt;
&lt;br /&gt;
* Testing&lt;br /&gt;
 cd /home/user/cfitsio/&lt;br /&gt;
 make speed # measures the maximum throughput (in MB per second) for writing and reading FITS files with CFITSIO &lt;br /&gt;
 ./speed&lt;br /&gt;
 make listhead # lists all the header keywords in any FITS file&lt;br /&gt;
 ./listhead&lt;br /&gt;
 make fitscopy # copies any FITS file&lt;br /&gt;
 ./fitscopy&lt;br /&gt;
 make cookbook # a sample program that performs common read and write operations on a FITS file.&lt;br /&gt;
 ./cookbook&lt;br /&gt;
&lt;br /&gt;
* Compiling &lt;br /&gt;
** #include &amp;quot;fitsio.h&amp;quot; # Include in any .c program to use cfitsio library&lt;br /&gt;
  gcc -o iter_a iter_a.c -lcfitsio -lm &lt;br /&gt;
  ./iter_a&lt;br /&gt;
&lt;br /&gt;
The typical libraries that need to be added are &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lm&amp;lt;/font&amp;gt; (the math library) and &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lnsl&amp;lt;/font&amp;gt; and &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lsocket&amp;lt;/font&amp;gt; (needed only for FTP and HTTP file access).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[http://www.stsci.edu/resources/software_hardware/pyfits Pyfits] can be easily installed from the source:&lt;br /&gt;
 wget  http://www.stsci.edu/resources/software_hardware/pyfits/pyfits-2.3.1.tar.gz &lt;br /&gt;
 tar xvf pyfits-2.3.1.tar.gz&lt;br /&gt;
 cd pyfits-2.3.1/&lt;br /&gt;
 sudo  python setup.py install # To install in Python's site-packages directory (recommended)&lt;br /&gt;
OR &lt;br /&gt;
 sudo python setup.py install --prefix=&amp;quot;/destination/directory/&amp;quot;  # Wherever you want&lt;br /&gt;
&lt;br /&gt;
== [http://tdc-www.harvard.edu/software/wcstools/index.html WCSTools] ==&lt;br /&gt;
&lt;br /&gt;
WCSTools is a package of programs and a library of utility subroutines for setting and using the world coordinate systems (WCS) in the headers of the most common astronomical image formats, FITS and IRAF .imh, to relate image pixels to sky coordinates. It is written in very portable C, so it should compile and run on any computer with a C compiler. &lt;br /&gt;
&lt;br /&gt;
* WCS Tools installation&lt;br /&gt;
&lt;br /&gt;
Download the latest version of WCS tools, which is at the moment (August, 2010) [http://tdc-www.harvard.edu/software/wcstools/wcstools-3.8.1.tar.gz wcstools-3.8.1]. Unpack it:&lt;br /&gt;
 tar xvf wcstools-3.8.1.tar.gz&lt;br /&gt;
 cd wcstools-3.8.1&lt;br /&gt;
 export CC=gcc&lt;br /&gt;
 sudo make&lt;br /&gt;
 sudo mkdir -p /usr/wcstools/&lt;br /&gt;
 sudo mv bin /usr/wcstools &lt;br /&gt;
Open your .basrc file (in your home dir) and add the following lines:&lt;br /&gt;
 #WCSTools&lt;br /&gt;
 PATH=$PATH:/usr/wcstools/bin&lt;br /&gt;
 export PATH &lt;br /&gt;
Restart the xterm or type: &lt;br /&gt;
 source ~/.bashrc&lt;br /&gt;
&lt;br /&gt;
Now you have all wcstool commands available from the terminal:&lt;br /&gt;
 &lt;br /&gt;
 addpix   delwcs    getdate  imextract  imsmooth  keyhead  simpos   xy2sky&lt;br /&gt;
 bincat   edhead    getfits  imfill     imstack   nedpos   sky2xy&lt;br /&gt;
 char2sp  filename  gethead  imhead     imstar    newfits  skycoor&lt;br /&gt;
 conpix   fileroot  getpix   immatch    imwcs     remap    sp2char&lt;br /&gt;
 cphead   filext    gettab   imresize   isfits    scat     subpix&lt;br /&gt;
 crlf     fixpix    i2f      imrot      isnum     sethead  sumpix&lt;br /&gt;
 delhead  getcol    imcat    imsize     isrange   setpix   wcshead&lt;br /&gt;
&lt;br /&gt;
Enjoy!&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=Astro_links&amp;diff=119</id>
		<title>Astro links</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=Astro_links&amp;diff=119"/>
		<updated>2023-12-05T12:43:31Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* STSDAS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== [http://stsdas.stsci.edu/irafx STSDAS] ===&lt;br /&gt;
&lt;br /&gt;
In Ubuntu install IRAF using Synaptic. Than download STSDAS from http://stsdas.stsci.edu/irafx/stsdas.linux.tar.gz. Unpack, go to stsci_iraf_x dir and start ./install_helper. Export IRAF: export iraf='/home/user/.iraf/' from the terminal and start installer again. The following text will apear:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
reset   tables          = /home/user/stsci_iraf_x/tables/&lt;br /&gt;
task    tables.pkg      = tables$tables.cl&lt;br /&gt;
if (access(&amp;quot;tables$lib&amp;quot;)) reset helpdb= ( envget(&amp;quot;helpdb&amp;quot;) + &amp;quot;,tables$lib/helpdb.mip&amp;quot; )  &lt;br /&gt;
&lt;br /&gt;
reset   stsdas          = /home/user/stsci_iraf_x/stsdas/&lt;br /&gt;
task    stsdas.pkg      = stsdas$stsdas.cl&lt;br /&gt;
task    apropos         = stsdas$apropos.cl&lt;br /&gt;
if (access(&amp;quot;stsdas$lib&amp;quot;)) reset helpdb= ( envget(&amp;quot;helpdb&amp;quot;) + &amp;quot;,stsdas$lib/helpdb.mip&amp;quot; )  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the text, start xgterm from terminal, then cl in the xgterm and when iraf starts paste these two lines. Just check if the stsci_iraf_x folder is in the right place. Afterwards, you can normally use stsdas and tables.&lt;br /&gt;
&lt;br /&gt;
=== [http://www.stsci.edu/resources/software_hardware/pyraf/current/download PYRAF] ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font color=red&amp;gt;''This pyraf goes with iraf, so first you have to install [http://wiki.ipb.ac.rs/index.php/IrafInstallation iraf].&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Download the latest pyraf release:&lt;br /&gt;
&lt;br /&gt;
wget http://stsdas.stsci.edu/download/pyraf/pyraf-1.9.tar.gz . # Check if this is still the latest release!!!&amp;lt;br&amp;gt;&lt;br /&gt;
tar xvf pyraf-1.9.tar.gz&amp;lt;br&amp;gt;&lt;br /&gt;
rm pyraf-1.9.tar.gz&amp;lt;br&amp;gt;&lt;br /&gt;
cd pytools&amp;lt;br&amp;gt;&lt;br /&gt;
sudo python setup.py install # This should go smoothly &amp;lt;br&amp;gt;&lt;br /&gt;
cd ../pyraf-1.9&amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install libx11-dev # Solved: Error &amp;quot;X11/X.h: No such file or directory&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
sudo apt-get install python-tk&amp;lt;br&amp;gt;&lt;br /&gt;
sudo python setup.py install &lt;br /&gt;
* In the case of error &amp;quot;Python.h missing&amp;quot; install the latest &amp;lt;font color=blue&amp;gt;python&amp;lt;/font&amp;gt; and &amp;lt;font color=blue&amp;gt;python-dev&amp;lt;/font&amp;gt; (python2.5 and python2.5-dev for Ubuntu 8.04) using synaptic&amp;lt;br&amp;gt;&lt;br /&gt;
* Check if you have &amp;lt;font color=blue&amp;gt;gcc&amp;lt;/font&amp;gt; and &amp;lt;font color=blue&amp;gt;gfortran&amp;lt;/font&amp;gt;, if not install:&amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install gcc&amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install gfortran&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Try to run again &amp;lt;font color=green&amp;gt; sudo python setup.py install &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* And run &amp;lt;font color=green&amp;gt; sudo python setup.py install &amp;lt;/font&amp;gt; again. If it reports that numpy is missing go to [http://sourceforge.net/projects/numpy/files/ SourceForge] and download source:&lt;br /&gt;
cd ../.&amp;lt;br&amp;gt;&lt;br /&gt;
wget http://sourceforge.net/projects/numpy/files/NumPy/1.4.1/numpy-1.4.1.tar.gz/download . # Check if this is the latest version&amp;lt;br&amp;gt;&lt;br /&gt;
tar xvf numpy-1.4.1.tar.gz&amp;lt;br&amp;gt;&lt;br /&gt;
cd numpy-1.4.1/&lt;br /&gt;
* Follow the instructions in INSTALL.txt, that are for Ubuntu 8.04. - 10.04:&lt;br /&gt;
sudo apt-get install libatlas-base-dev &amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install libatlas3gf-sse2 &amp;lt;br&amp;gt;&lt;br /&gt;
sudo python setup.py install &amp;lt;br&amp;gt;&lt;br /&gt;
* Go back to pyraf-1.9 directory and repeat&lt;br /&gt;
sudo python setup.py install &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should work!!!&lt;br /&gt;
&lt;br /&gt;
=== [http://heasarc.gsfc.nasa.gov/fitsio/ CFITSIO] ===&lt;br /&gt;
&lt;br /&gt;
CFITSIO is a library of C and Fortran subroutines for reading and writing data files in FITS. Installation under Linux (Ubuntu 8.04) with/without multithreading.&lt;br /&gt;
* Installation under Ubuntu 8.04&lt;br /&gt;
 cd /home/user/&lt;br /&gt;
 wget ftp://heasarc.gsfc.nasa.gov/software/fitsio/c/cfitsio3240.tar.gz . # Check for the latest version under [http://heasarc.gsfc.nasa.gov/fitsio/ Unix .tar file]&lt;br /&gt;
 tar zxvf cfitsio3240.tar.gz&lt;br /&gt;
 cd cfitsio/&lt;br /&gt;
  ./configure CC=gcc &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;--enable-reentrant&amp;lt;/font&amp;gt; # &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt; WITH MULTITHREAD&amp;lt;/font&amp;gt;&lt;br /&gt;
  make shared  # &amp;lt;small&amp;gt;builds a shared or dynamic version of the CFITSIO library saving the disk space, memory &amp;lt;/small&amp;gt; &lt;br /&gt;
  # &amp;lt;small&amp;gt; and enables easier maintenance since a new version of the shared library can be installed without relinking all the software that uses it &amp;lt;/small&amp;gt;&lt;br /&gt;
  make install&lt;br /&gt;
  make testprog&lt;br /&gt;
  ./testprog &amp;gt; testprog.lis&lt;br /&gt;
  diff testprog.lis testprog.out # There should not be any output &lt;br /&gt;
  cmp testprog.fit testprog.std  # There should not be any output&lt;br /&gt;
  sudo apt-get install happycoders-libsocket happycoders-libsocket-dev&lt;br /&gt;
  cd /usr/lib/&lt;br /&gt;
  sudo ln -s /usr/lib/happycoders/libsocket.so .&lt;br /&gt;
&lt;br /&gt;
* Proper linking (add in .bashrc file)&lt;br /&gt;
&lt;br /&gt;
 C_INCLUDE_PATH=/home/user/cfitsio/include&lt;br /&gt;
 LIBRARY_PATH=/home/user/cfitsio/lib&lt;br /&gt;
 export C_INCLUDE_PATH LIBRARY_PATH&lt;br /&gt;
&lt;br /&gt;
* Testing&lt;br /&gt;
 cd /home/user/cfitsio/&lt;br /&gt;
 make speed # measures the maximum throughput (in MB per second) for writing and reading FITS files with CFITSIO &lt;br /&gt;
 ./speed&lt;br /&gt;
 make listhead # lists all the header keywords in any FITS file&lt;br /&gt;
 ./listhead&lt;br /&gt;
 make fitscopy # copies any FITS file&lt;br /&gt;
 ./fitscopy&lt;br /&gt;
 make cookbook # a sample program that performs common read and write operations on a FITS file.&lt;br /&gt;
 ./cookbook&lt;br /&gt;
&lt;br /&gt;
* Compiling &lt;br /&gt;
** #include &amp;quot;fitsio.h&amp;quot; # Include in any .c program to use cfitsio library&lt;br /&gt;
  gcc -o iter_a iter_a.c -lcfitsio -lm &lt;br /&gt;
  ./iter_a&lt;br /&gt;
&lt;br /&gt;
The typical libraries that need to be added are &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lm&amp;lt;/font&amp;gt; (the math library) and &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lnsl&amp;lt;/font&amp;gt; and &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lsocket&amp;lt;/font&amp;gt; (needed only for FTP and HTTP file access).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[http://www.stsci.edu/resources/software_hardware/pyfits Pyfits] can be easily installed from the source:&lt;br /&gt;
 wget  http://www.stsci.edu/resources/software_hardware/pyfits/pyfits-2.3.1.tar.gz &lt;br /&gt;
 tar xvf pyfits-2.3.1.tar.gz&lt;br /&gt;
 cd pyfits-2.3.1/&lt;br /&gt;
 sudo  python setup.py install # To install in Python's site-packages directory (recommended)&lt;br /&gt;
OR &lt;br /&gt;
 sudo python setup.py install --prefix=&amp;quot;/destination/directory/&amp;quot;  # Wherever you want&lt;br /&gt;
&lt;br /&gt;
== [http://tdc-www.harvard.edu/software/wcstools/index.html WCSTools] ==&lt;br /&gt;
&lt;br /&gt;
WCSTools is a package of programs and a library of utility subroutines for setting and using the world coordinate systems (WCS) in the headers of the most common astronomical image formats, FITS and IRAF .imh, to relate image pixels to sky coordinates. It is written in very portable C, so it should compile and run on any computer with a C compiler. &lt;br /&gt;
&lt;br /&gt;
* WCS Tools installation&lt;br /&gt;
&lt;br /&gt;
Download the latest version of WCS tools, which is at the moment (August, 2010) [http://tdc-www.harvard.edu/software/wcstools/wcstools-3.8.1.tar.gz wcstools-3.8.1]. Unpack it:&lt;br /&gt;
 tar xvf wcstools-3.8.1.tar.gz&lt;br /&gt;
 cd wcstools-3.8.1&lt;br /&gt;
 export CC=gcc&lt;br /&gt;
 sudo make&lt;br /&gt;
 sudo mkdir -p /usr/wcstools/&lt;br /&gt;
 sudo mv bin /usr/wcstools &lt;br /&gt;
Open your .basrc file (in your home dir) and add the following lines:&lt;br /&gt;
 #WCSTools&lt;br /&gt;
 PATH=$PATH:/usr/wcstools/bin&lt;br /&gt;
 export PATH &lt;br /&gt;
Restart the xterm or type: &lt;br /&gt;
 source ~/.bashrc&lt;br /&gt;
&lt;br /&gt;
Now you have all wcstool commands available from the terminal:&lt;br /&gt;
 &lt;br /&gt;
 addpix   delwcs    getdate  imextract  imsmooth  keyhead  simpos   xy2sky&lt;br /&gt;
 bincat   edhead    getfits  imfill     imstack   nedpos   sky2xy&lt;br /&gt;
 char2sp  filename  gethead  imhead     imstar    newfits  skycoor&lt;br /&gt;
 conpix   fileroot  getpix   immatch    imwcs     remap    sp2char&lt;br /&gt;
 cphead   filext    gettab   imresize   isfits    scat     subpix&lt;br /&gt;
 crlf     fixpix    i2f      imrot      isnum     sethead  sumpix&lt;br /&gt;
 delhead  getcol    imcat    imsize     isrange   setpix   wcshead&lt;br /&gt;
&lt;br /&gt;
Enjoy!&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=Astro_links&amp;diff=118</id>
		<title>Astro links</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=Astro_links&amp;diff=118"/>
		<updated>2023-11-30T10:51:29Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== [http://stsdas.stsci.edu/irafx STSDAS] ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== [http://www.stsci.edu/resources/software_hardware/pyraf/current/download PYRAF] ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font color=red&amp;gt;''This pyraf goes with iraf, so first you have to install [http://wiki.ipb.ac.rs/index.php/IrafInstallation iraf].&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Download the latest pyraf release:&lt;br /&gt;
&lt;br /&gt;
wget http://stsdas.stsci.edu/download/pyraf/pyraf-1.9.tar.gz . # Check if this is still the latest release!!!&amp;lt;br&amp;gt;&lt;br /&gt;
tar xvf pyraf-1.9.tar.gz&amp;lt;br&amp;gt;&lt;br /&gt;
rm pyraf-1.9.tar.gz&amp;lt;br&amp;gt;&lt;br /&gt;
cd pytools&amp;lt;br&amp;gt;&lt;br /&gt;
sudo python setup.py install # This should go smoothly &amp;lt;br&amp;gt;&lt;br /&gt;
cd ../pyraf-1.9&amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install libx11-dev # Solved: Error &amp;quot;X11/X.h: No such file or directory&amp;quot;&amp;lt;br&amp;gt; &lt;br /&gt;
sudo apt-get install python-tk&amp;lt;br&amp;gt;&lt;br /&gt;
sudo python setup.py install &lt;br /&gt;
* In the case of error &amp;quot;Python.h missing&amp;quot; install the latest &amp;lt;font color=blue&amp;gt;python&amp;lt;/font&amp;gt; and &amp;lt;font color=blue&amp;gt;python-dev&amp;lt;/font&amp;gt; (python2.5 and python2.5-dev for Ubuntu 8.04) using synaptic&amp;lt;br&amp;gt;&lt;br /&gt;
* Check if you have &amp;lt;font color=blue&amp;gt;gcc&amp;lt;/font&amp;gt; and &amp;lt;font color=blue&amp;gt;gfortran&amp;lt;/font&amp;gt;, if not install:&amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install gcc&amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install gfortran&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Try to run again &amp;lt;font color=green&amp;gt; sudo python setup.py install &amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* And run &amp;lt;font color=green&amp;gt; sudo python setup.py install &amp;lt;/font&amp;gt; again. If it reports that numpy is missing go to [http://sourceforge.net/projects/numpy/files/ SourceForge] and download source:&lt;br /&gt;
cd ../.&amp;lt;br&amp;gt;&lt;br /&gt;
wget http://sourceforge.net/projects/numpy/files/NumPy/1.4.1/numpy-1.4.1.tar.gz/download . # Check if this is the latest version&amp;lt;br&amp;gt;&lt;br /&gt;
tar xvf numpy-1.4.1.tar.gz&amp;lt;br&amp;gt;&lt;br /&gt;
cd numpy-1.4.1/&lt;br /&gt;
* Follow the instructions in INSTALL.txt, that are for Ubuntu 8.04. - 10.04:&lt;br /&gt;
sudo apt-get install libatlas-base-dev &amp;lt;br&amp;gt;&lt;br /&gt;
sudo apt-get install libatlas3gf-sse2 &amp;lt;br&amp;gt;&lt;br /&gt;
sudo python setup.py install &amp;lt;br&amp;gt;&lt;br /&gt;
* Go back to pyraf-1.9 directory and repeat&lt;br /&gt;
sudo python setup.py install &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should work!!!&lt;br /&gt;
&lt;br /&gt;
=== [http://heasarc.gsfc.nasa.gov/fitsio/ CFITSIO] ===&lt;br /&gt;
&lt;br /&gt;
CFITSIO is a library of C and Fortran subroutines for reading and writing data files in FITS. Installation under Linux (Ubuntu 8.04) with/without multithreading.&lt;br /&gt;
* Installation under Ubuntu 8.04&lt;br /&gt;
 cd /home/user/&lt;br /&gt;
 wget ftp://heasarc.gsfc.nasa.gov/software/fitsio/c/cfitsio3240.tar.gz . # Check for the latest version under [http://heasarc.gsfc.nasa.gov/fitsio/ Unix .tar file]&lt;br /&gt;
 tar zxvf cfitsio3240.tar.gz&lt;br /&gt;
 cd cfitsio/&lt;br /&gt;
  ./configure CC=gcc &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;--enable-reentrant&amp;lt;/font&amp;gt; # &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt; WITH MULTITHREAD&amp;lt;/font&amp;gt;&lt;br /&gt;
  make shared  # &amp;lt;small&amp;gt;builds a shared or dynamic version of the CFITSIO library saving the disk space, memory &amp;lt;/small&amp;gt; &lt;br /&gt;
  # &amp;lt;small&amp;gt; and enables easier maintenance since a new version of the shared library can be installed without relinking all the software that uses it &amp;lt;/small&amp;gt;&lt;br /&gt;
  make install&lt;br /&gt;
  make testprog&lt;br /&gt;
  ./testprog &amp;gt; testprog.lis&lt;br /&gt;
  diff testprog.lis testprog.out # There should not be any output &lt;br /&gt;
  cmp testprog.fit testprog.std  # There should not be any output&lt;br /&gt;
  sudo apt-get install happycoders-libsocket happycoders-libsocket-dev&lt;br /&gt;
  cd /usr/lib/&lt;br /&gt;
  sudo ln -s /usr/lib/happycoders/libsocket.so .&lt;br /&gt;
&lt;br /&gt;
* Proper linking (add in .bashrc file)&lt;br /&gt;
&lt;br /&gt;
 C_INCLUDE_PATH=/home/user/cfitsio/include&lt;br /&gt;
 LIBRARY_PATH=/home/user/cfitsio/lib&lt;br /&gt;
 export C_INCLUDE_PATH LIBRARY_PATH&lt;br /&gt;
&lt;br /&gt;
* Testing&lt;br /&gt;
 cd /home/user/cfitsio/&lt;br /&gt;
 make speed # measures the maximum throughput (in MB per second) for writing and reading FITS files with CFITSIO &lt;br /&gt;
 ./speed&lt;br /&gt;
 make listhead # lists all the header keywords in any FITS file&lt;br /&gt;
 ./listhead&lt;br /&gt;
 make fitscopy # copies any FITS file&lt;br /&gt;
 ./fitscopy&lt;br /&gt;
 make cookbook # a sample program that performs common read and write operations on a FITS file.&lt;br /&gt;
 ./cookbook&lt;br /&gt;
&lt;br /&gt;
* Compiling &lt;br /&gt;
** #include &amp;quot;fitsio.h&amp;quot; # Include in any .c program to use cfitsio library&lt;br /&gt;
  gcc -o iter_a iter_a.c -lcfitsio -lm &lt;br /&gt;
  ./iter_a&lt;br /&gt;
&lt;br /&gt;
The typical libraries that need to be added are &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lm&amp;lt;/font&amp;gt; (the math library) and &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lnsl&amp;lt;/font&amp;gt; and &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lsocket&amp;lt;/font&amp;gt; (needed only for FTP and HTTP file access).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[http://www.stsci.edu/resources/software_hardware/pyfits Pyfits] can be easily installed from the source:&lt;br /&gt;
 wget  http://www.stsci.edu/resources/software_hardware/pyfits/pyfits-2.3.1.tar.gz &lt;br /&gt;
 tar xvf pyfits-2.3.1.tar.gz&lt;br /&gt;
 cd pyfits-2.3.1/&lt;br /&gt;
 sudo  python setup.py install # To install in Python's site-packages directory (recommended)&lt;br /&gt;
OR &lt;br /&gt;
 sudo python setup.py install --prefix=&amp;quot;/destination/directory/&amp;quot;  # Wherever you want&lt;br /&gt;
&lt;br /&gt;
== [http://tdc-www.harvard.edu/software/wcstools/index.html WCSTools] ==&lt;br /&gt;
&lt;br /&gt;
WCSTools is a package of programs and a library of utility subroutines for setting and using the world coordinate systems (WCS) in the headers of the most common astronomical image formats, FITS and IRAF .imh, to relate image pixels to sky coordinates. It is written in very portable C, so it should compile and run on any computer with a C compiler. &lt;br /&gt;
&lt;br /&gt;
* WCS Tools installation&lt;br /&gt;
&lt;br /&gt;
Download the latest version of WCS tools, which is at the moment (August, 2010) [http://tdc-www.harvard.edu/software/wcstools/wcstools-3.8.1.tar.gz wcstools-3.8.1]. Unpack it:&lt;br /&gt;
 tar xvf wcstools-3.8.1.tar.gz&lt;br /&gt;
 cd wcstools-3.8.1&lt;br /&gt;
 export CC=gcc&lt;br /&gt;
 sudo make&lt;br /&gt;
 sudo mkdir -p /usr/wcstools/&lt;br /&gt;
 sudo mv bin /usr/wcstools &lt;br /&gt;
Open your .basrc file (in your home dir) and add the following lines:&lt;br /&gt;
 #WCSTools&lt;br /&gt;
 PATH=$PATH:/usr/wcstools/bin&lt;br /&gt;
 export PATH &lt;br /&gt;
Restart the xterm or type: &lt;br /&gt;
 source ~/.bashrc&lt;br /&gt;
&lt;br /&gt;
Now you have all wcstool commands available from the terminal:&lt;br /&gt;
 &lt;br /&gt;
 addpix   delwcs    getdate  imextract  imsmooth  keyhead  simpos   xy2sky&lt;br /&gt;
 bincat   edhead    getfits  imfill     imstack   nedpos   sky2xy&lt;br /&gt;
 char2sp  filename  gethead  imhead     imstar    newfits  skycoor&lt;br /&gt;
 conpix   fileroot  getpix   immatch    imwcs     remap    sp2char&lt;br /&gt;
 cphead   filext    gettab   imresize   isfits    scat     subpix&lt;br /&gt;
 crlf     fixpix    i2f      imrot      isnum     sethead  sumpix&lt;br /&gt;
 delhead  getcol    imcat    imsize     isrange   setpix   wcshead&lt;br /&gt;
&lt;br /&gt;
Enjoy!&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=Astro_links&amp;diff=117</id>
		<title>Astro links</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=Astro_links&amp;diff=117"/>
		<updated>2023-11-30T10:47:44Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== [http://stsdas.stsci.edu/irafx STSDAS] ===&lt;br /&gt;
&lt;br /&gt;
=== [http://heasarc.gsfc.nasa.gov/fitsio/ CFITSIO] ===&lt;br /&gt;
&lt;br /&gt;
CFITSIO is a library of C and Fortran subroutines for reading and writing data files in FITS. Installation under Linux (Ubuntu 8.04) with/without multithreading.&lt;br /&gt;
* Installation under Ubuntu 8.04&lt;br /&gt;
 cd /home/user/&lt;br /&gt;
 wget ftp://heasarc.gsfc.nasa.gov/software/fitsio/c/cfitsio3240.tar.gz . # Check for the latest version under [http://heasarc.gsfc.nasa.gov/fitsio/ Unix .tar file]&lt;br /&gt;
 tar zxvf cfitsio3240.tar.gz&lt;br /&gt;
 cd cfitsio/&lt;br /&gt;
  ./configure CC=gcc &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;--enable-reentrant&amp;lt;/font&amp;gt; # &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt; WITH MULTITHREAD&amp;lt;/font&amp;gt;&lt;br /&gt;
  make shared  # &amp;lt;small&amp;gt;builds a shared or dynamic version of the CFITSIO library saving the disk space, memory &amp;lt;/small&amp;gt; &lt;br /&gt;
  # &amp;lt;small&amp;gt; and enables easier maintenance since a new version of the shared library can be installed without relinking all the software that uses it &amp;lt;/small&amp;gt;&lt;br /&gt;
  make install&lt;br /&gt;
  make testprog&lt;br /&gt;
  ./testprog &amp;gt; testprog.lis&lt;br /&gt;
  diff testprog.lis testprog.out # There should not be any output &lt;br /&gt;
  cmp testprog.fit testprog.std  # There should not be any output&lt;br /&gt;
  sudo apt-get install happycoders-libsocket happycoders-libsocket-dev&lt;br /&gt;
  cd /usr/lib/&lt;br /&gt;
  sudo ln -s /usr/lib/happycoders/libsocket.so .&lt;br /&gt;
&lt;br /&gt;
* Proper linking (add in .bashrc file)&lt;br /&gt;
&lt;br /&gt;
 C_INCLUDE_PATH=/home/user/cfitsio/include&lt;br /&gt;
 LIBRARY_PATH=/home/user/cfitsio/lib&lt;br /&gt;
 export C_INCLUDE_PATH LIBRARY_PATH&lt;br /&gt;
&lt;br /&gt;
* Testing&lt;br /&gt;
 cd /home/user/cfitsio/&lt;br /&gt;
 make speed # measures the maximum throughput (in MB per second) for writing and reading FITS files with CFITSIO &lt;br /&gt;
 ./speed&lt;br /&gt;
 make listhead # lists all the header keywords in any FITS file&lt;br /&gt;
 ./listhead&lt;br /&gt;
 make fitscopy # copies any FITS file&lt;br /&gt;
 ./fitscopy&lt;br /&gt;
 make cookbook # a sample program that performs common read and write operations on a FITS file.&lt;br /&gt;
 ./cookbook&lt;br /&gt;
&lt;br /&gt;
* Compiling &lt;br /&gt;
** #include &amp;quot;fitsio.h&amp;quot; # Include in any .c program to use cfitsio library&lt;br /&gt;
  gcc -o iter_a iter_a.c -lcfitsio -lm &lt;br /&gt;
  ./iter_a&lt;br /&gt;
&lt;br /&gt;
The typical libraries that need to be added are &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lm&amp;lt;/font&amp;gt; (the math library) and &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lnsl&amp;lt;/font&amp;gt; and &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lsocket&amp;lt;/font&amp;gt; (needed only for FTP and HTTP file access).&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=Astro_links&amp;diff=116</id>
		<title>Astro links</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=Astro_links&amp;diff=116"/>
		<updated>2023-11-30T10:47:29Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== [http://stsdas.stsci.edu/irafx STSDAS] ==&lt;br /&gt;
&lt;br /&gt;
=== [http://heasarc.gsfc.nasa.gov/fitsio/ CFITSIO] ===&lt;br /&gt;
&lt;br /&gt;
CFITSIO is a library of C and Fortran subroutines for reading and writing data files in FITS. Installation under Linux (Ubuntu 8.04) with/without multithreading.&lt;br /&gt;
* Installation under Ubuntu 8.04&lt;br /&gt;
 cd /home/user/&lt;br /&gt;
 wget ftp://heasarc.gsfc.nasa.gov/software/fitsio/c/cfitsio3240.tar.gz . # Check for the latest version under [http://heasarc.gsfc.nasa.gov/fitsio/ Unix .tar file]&lt;br /&gt;
 tar zxvf cfitsio3240.tar.gz&lt;br /&gt;
 cd cfitsio/&lt;br /&gt;
  ./configure CC=gcc &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;--enable-reentrant&amp;lt;/font&amp;gt; # &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt; WITH MULTITHREAD&amp;lt;/font&amp;gt;&lt;br /&gt;
  make shared  # &amp;lt;small&amp;gt;builds a shared or dynamic version of the CFITSIO library saving the disk space, memory &amp;lt;/small&amp;gt; &lt;br /&gt;
  # &amp;lt;small&amp;gt; and enables easier maintenance since a new version of the shared library can be installed without relinking all the software that uses it &amp;lt;/small&amp;gt;&lt;br /&gt;
  make install&lt;br /&gt;
  make testprog&lt;br /&gt;
  ./testprog &amp;gt; testprog.lis&lt;br /&gt;
  diff testprog.lis testprog.out # There should not be any output &lt;br /&gt;
  cmp testprog.fit testprog.std  # There should not be any output&lt;br /&gt;
  sudo apt-get install happycoders-libsocket happycoders-libsocket-dev&lt;br /&gt;
  cd /usr/lib/&lt;br /&gt;
  sudo ln -s /usr/lib/happycoders/libsocket.so .&lt;br /&gt;
&lt;br /&gt;
* Proper linking (add in .bashrc file)&lt;br /&gt;
&lt;br /&gt;
 C_INCLUDE_PATH=/home/user/cfitsio/include&lt;br /&gt;
 LIBRARY_PATH=/home/user/cfitsio/lib&lt;br /&gt;
 export C_INCLUDE_PATH LIBRARY_PATH&lt;br /&gt;
&lt;br /&gt;
* Testing&lt;br /&gt;
 cd /home/user/cfitsio/&lt;br /&gt;
 make speed # measures the maximum throughput (in MB per second) for writing and reading FITS files with CFITSIO &lt;br /&gt;
 ./speed&lt;br /&gt;
 make listhead # lists all the header keywords in any FITS file&lt;br /&gt;
 ./listhead&lt;br /&gt;
 make fitscopy # copies any FITS file&lt;br /&gt;
 ./fitscopy&lt;br /&gt;
 make cookbook # a sample program that performs common read and write operations on a FITS file.&lt;br /&gt;
 ./cookbook&lt;br /&gt;
&lt;br /&gt;
* Compiling &lt;br /&gt;
** #include &amp;quot;fitsio.h&amp;quot; # Include in any .c program to use cfitsio library&lt;br /&gt;
  gcc -o iter_a iter_a.c -lcfitsio -lm &lt;br /&gt;
  ./iter_a&lt;br /&gt;
&lt;br /&gt;
The typical libraries that need to be added are &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lm&amp;lt;/font&amp;gt; (the math library) and &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lnsl&amp;lt;/font&amp;gt; and &amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;-lsocket&amp;lt;/font&amp;gt; (needed only for FTP and HTTP file access).&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=Astro_links&amp;diff=115</id>
		<title>Astro links</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=Astro_links&amp;diff=115"/>
		<updated>2023-11-30T10:45:06Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;# STSDAS: http://stsdas.stsci.edu/irafx&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=Astro_links&amp;diff=114</id>
		<title>Astro links</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=Astro_links&amp;diff=114"/>
		<updated>2023-11-30T10:44:31Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: Created page with &amp;quot;# STSDAS: stsdas.stsci.edu/irafx&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;# STSDAS: stsdas.stsci.edu/irafx&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=IRAF4Students&amp;diff=113</id>
		<title>IRAF4Students</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=IRAF4Students&amp;diff=113"/>
		<updated>2023-11-27T14:56:48Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: Created page with &amp;quot;&amp;lt;pre&amp;gt;  Author: Milan Bogosavljevic  pokreni ds9 &amp;amp; pokreni xgterm komanda ispod pokreni irafcl posle toga step 2   # AOB I Katedra za astronomiju # SVAP Maj, 2015  # Priprema z...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Author: Milan Bogosavljevic&lt;br /&gt;
&lt;br /&gt;
pokreni ds9 &amp;amp;&lt;br /&gt;
pokreni xgterm komanda ispod&lt;br /&gt;
pokreni irafcl&lt;br /&gt;
posle toga step 2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# AOB I Katedra za astronomiju&lt;br /&gt;
# SVAP Maj, 2015&lt;br /&gt;
&lt;br /&gt;
# Priprema za obradu podataka i fotometriju u IRAF-u&lt;br /&gt;
# Folder &amp;quot;raw&amp;quot; - sadrzi sirova posmatranja: kalibracione snimke i &lt;br /&gt;
# snimke polja u kome se nalazi objekat Qatar-2b&lt;br /&gt;
# http://www.openexoplanetcatalogue.com/planet/Qatar-2%20b/&lt;br /&gt;
# http://var2.astro.cz/ETD/predict_detail.php?STARNAME=Qatar-2&amp;amp;PLANET=b&amp;amp;PER=&amp;amp;M=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###############################&lt;br /&gt;
## Step 1:&lt;br /&gt;
## These are general guidelines for a fresh start in using IRAF&lt;br /&gt;
###############################&lt;br /&gt;
&lt;br /&gt;
# 1) In Unix command prompt&lt;br /&gt;
# Set up IRAF, this sets some preferences and paths to where you are&lt;br /&gt;
# the file login.cl with general preferences will be created in&lt;br /&gt;
# current directory to take advantage of those preferences, &lt;br /&gt;
# you need to start IRAF from current directory&lt;br /&gt;
# choose xgterm when asked&lt;br /&gt;
&lt;br /&gt;
mkiraf&lt;br /&gt;
&lt;br /&gt;
# 2) edit the login.cl which was just created:&lt;br /&gt;
# uncomment the line for stdimage setting and&lt;br /&gt;
# increase the image buffer size to hold images up to 4096x4096 pixels&lt;br /&gt;
# the line should be like this (wihtout the # comment symbol):&lt;br /&gt;
# set     stdimage        = imt4096&lt;br /&gt;
&lt;br /&gt;
# 3) launch xgterm with some neat options like a scrollbar&lt;br /&gt;
&lt;br /&gt;
xgterm -sb -sl 1000 &amp;amp;&lt;br /&gt;
&lt;br /&gt;
# 4) Start the IRAF command prompt (from the directory where login.cl was created)&lt;br /&gt;
cl&lt;br /&gt;
&lt;br /&gt;
# start ds9&lt;br /&gt;
&lt;br /&gt;
!ds9 &amp;amp;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###############################&lt;br /&gt;
# Step 2: raw data processing in IRAF&lt;br /&gt;
# redux of 2012_05_09 data&lt;br /&gt;
# Qatar 2-b transit; Bogosavljevic/Sekulic; Vidojevica 60cm&lt;br /&gt;
###############################&lt;br /&gt;
&lt;br /&gt;
# While in IRAF command prompt:&lt;br /&gt;
# 5) make a folder called reduced and copy over raw files into that directory&lt;br /&gt;
# it is very advisable to always make this copy so that you can&lt;br /&gt;
# redo the process at any time by copying over the raw files &lt;br /&gt;
&lt;br /&gt;
 !mkdir reduced&lt;br /&gt;
 !cp ./raw/*fit reduced/&lt;br /&gt;
 cd reduced&lt;br /&gt;
&lt;br /&gt;
# 6) Proceeding with bias, dark, flat corrections of raw data&lt;br /&gt;
# make bias list of all Bias files &lt;br /&gt;
#(tip: fast and easy way to work in IRAF is to use lists)&lt;br /&gt;
&lt;br /&gt;
!ls Calib-1*Bias* &amp;gt; bias.list&lt;br /&gt;
&lt;br /&gt;
# 7) examine statistics of bias frames for uniformity&lt;br /&gt;
imstat.nclip = 3&lt;br /&gt;
imstat @bias.list &lt;br /&gt;
&lt;br /&gt;
# 8) take a look at one bias frame, examine it&lt;br /&gt;
&lt;br /&gt;
displ Calib-100_Bias.fit 1&lt;br /&gt;
&lt;br /&gt;
# 9) load ccdred package&lt;br /&gt;
&lt;br /&gt;
noao&lt;br /&gt;
imred &lt;br /&gt;
ccdred&lt;br /&gt;
&lt;br /&gt;
# 10) combine bias (also called &amp;quot;zero&amp;quot;) frames&lt;br /&gt;
&lt;br /&gt;
zerocombine @bias.list output=&amp;quot;Zero&amp;quot; combine=&amp;quot;median&amp;quot; reject=&amp;quot;minmax&amp;quot; ccdtype=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# NOTE:&lt;br /&gt;
# same can be done by editing the parameters of the procedure &amp;quot;zerocombine&amp;quot;&lt;br /&gt;
#  with &amp;quot;epar zerocombine&amp;quot; and just changing the above listed parameters &lt;br /&gt;
# (leave other as default), save and exit with &amp;quot;:q&amp;quot;,&lt;br /&gt;
# or run it with &amp;quot;:go&amp;quot;. If exit then run it &amp;quot;zerocombine&amp;quot;,&lt;br /&gt;
# pressing enter for questions. This applies to all below procedures in IRAF&lt;br /&gt;
 &lt;br /&gt;
# 11) examine the final combined frame called Zero&lt;br /&gt;
&lt;br /&gt;
displ Zero 2&lt;br /&gt;
imstat Zero&lt;br /&gt;
&lt;br /&gt;
# note the decrease in STDDEV&lt;br /&gt;
# note that the average bias level is 1376&lt;br /&gt;
&lt;br /&gt;
# 11) make dark list of all Dark files, check their statistics, see how they look like&lt;br /&gt;
&lt;br /&gt;
!ls Calib-1*D60* &amp;gt; dark60.list&lt;br /&gt;
imstat @dark60.list &lt;br /&gt;
displ  Calib-104_D60.fit 1&lt;br /&gt;
&lt;br /&gt;
# note that after 60seconds of integration, the average level in the CCD is about 1389&lt;br /&gt;
# the temperature of the camera was -25 Celsius&lt;br /&gt;
# which means that the dark current electrons added 1389 - 1376 = 13 ADU&lt;br /&gt;
# the units recorded by the CCD camera are ADU. The actual eletroncs are &lt;br /&gt;
# obtained when this number is divided by GAIN = 1.2 e-/ADU for this camera.&lt;br /&gt;
# so, we got about 13 / 1.2 = 10.8 e- of dark current in this case.&lt;br /&gt;
&lt;br /&gt;
# 12) processing darks (subtracting bias) and combinining them&lt;br /&gt;
# set some general parameters for ccdred and ccdproc for ASV CCD camera&lt;br /&gt;
&lt;br /&gt;
 ccdred.verbose=yes&lt;br /&gt;
 ccdproc.fixpix = no&lt;br /&gt;
 ccdproc.oversca = no&lt;br /&gt;
 ccdproc.trim = no&lt;br /&gt;
 ccdproc.ccdtype=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 ccdproc @dark60.list zero=&amp;quot;Zero&amp;quot; zerocor+ darkcor- flatcor- &lt;br /&gt;
&lt;br /&gt;
 darkcombine @dark60.list output=&amp;quot;Dark60&amp;quot; ccdtype=&amp;quot;&amp;quot; process- combine=&amp;quot;median&amp;quot; # reject=&amp;quot;minmax&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # Proces- switch means : do not process with ccdproc, as we have already did this &lt;br /&gt;
 # by hand, in the previous step&lt;br /&gt;
&lt;br /&gt;
# does the end result make sense?&lt;br /&gt;
 displ Dark60 1&lt;br /&gt;
 imstat Dark60&lt;br /&gt;
&lt;br /&gt;
# 13) make a list of twilight flatfield files in the V filter &lt;br /&gt;
# check their statistics, see how they look like&lt;br /&gt;
!ls TwiFlat-*V.fit &amp;gt; twiflat_V.list&lt;br /&gt;
imstat @twiflat_V.list &lt;br /&gt;
&lt;br /&gt;
# For flats, it is very important to check them all visually&lt;br /&gt;
displ TwiFlat-010_V.fit 1&lt;br /&gt;
displ TwiFlat-011_V.fit 2&lt;br /&gt;
displ TwiFlat-012_V.fit 3&lt;br /&gt;
displ TwiFlat-013_V.fit 4&lt;br /&gt;
displ TwiFlat-014_V.fit 5&lt;br /&gt;
&lt;br /&gt;
# what do you see if you flip trough these images (hit TAB key in DS9)?&lt;br /&gt;
# why is the light dropping of towards the edges?&lt;br /&gt;
# are there stars caught in the twilight flat?&lt;br /&gt;
# - we must get rid of those!&lt;br /&gt;
&lt;br /&gt;
# 14) process flats (subtract bias, dark) and combine them&lt;br /&gt;
&lt;br /&gt;
 ccdproc @twiflat_V.list zero=&amp;quot;Zero&amp;quot; dark=&amp;quot;Dark60&amp;quot; zerocor+ darkcor+ flatcor- &lt;br /&gt;
&lt;br /&gt;
# note that the dark frame used was Dark60,&lt;br /&gt;
#  and IRAF noted it was scaled to exposure of flats&lt;br /&gt;
&lt;br /&gt;
# 15) combine the processed flats&lt;br /&gt;
 flatcombine @twiflat_V.list output=&amp;quot;MasterFlatV&amp;quot; ccdtype=&amp;quot;&amp;quot; process- scale=&amp;quot;median&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# 16) examine the result&lt;br /&gt;
&lt;br /&gt;
 displ MasterFlatV 1&lt;br /&gt;
 &lt;br /&gt;
# NOTE: stars have been averaged out! This is why we must dither (move the telescope)&lt;br /&gt;
# slightly when taking twilight flat frames!&lt;br /&gt;
&lt;br /&gt;
# 17) Finally, processing science frames  &lt;br /&gt;
# subtracting bias, dark and then flatfielding all of them&lt;br /&gt;
!ls Qatar2b-*fit &amp;gt; qatar.list&lt;br /&gt;
&lt;br /&gt;
ccdproc @qatar.list zero=&amp;quot;Zero&amp;quot; dark=&amp;quot;Dark60&amp;quot; flat=&amp;quot;MasterFlatV&amp;quot; zerocor+ darkcor+ flatcor+&lt;br /&gt;
&lt;br /&gt;
# with the above 3 steps you finished the data reduction in IRAF (bias, flat field, dark correction)&lt;br /&gt;
# next you move to the magnitude measurements&lt;br /&gt;
&lt;br /&gt;
# 18) Check the header of any of the finally processed data frames:&lt;br /&gt;
&lt;br /&gt;
 imhead Qatar2b-239_V.fit l+&lt;br /&gt;
&lt;br /&gt;
# This is how a finished processing job should look like at the end:&lt;br /&gt;
#ZEROCOR = 'May 19 14:13 Zero level correction image is Zero'&lt;br /&gt;
#DARKCOR = 'May 19 14:13 Dark count correction image is Dark60 with scale=1.'&lt;br /&gt;
#FLATCOR = 'May 19 14:13 Flat field image is MasterFlatV with scale=30623.51'&lt;br /&gt;
#CCDSEC  = '[1:2048,1:2048]'&lt;br /&gt;
#CCDMEAN =             536.6693&lt;br /&gt;
#CCDMEANT=           1116511997&lt;br /&gt;
#CCDPROC = 'May 19 14:13 CCD processing done'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 # 19) Go to DS9 and remove all current frames by going in the menu:&lt;br /&gt;
 # Frame -&amp;gt; Delete All Frames&lt;br /&gt;
 # now compare a raw and processed science frame&lt;br /&gt;
&lt;br /&gt;
 displ ../raw/Qatar2b-239_V.fit 1 zscale+&lt;br /&gt;
 displ Qatar2b-239_V.fit 2 zscale+&lt;br /&gt;
&lt;br /&gt;
 # you can also press scale and select zscale in the DS9 window&lt;br /&gt;
 # compare the two images&lt;br /&gt;
 # what have we gained?&lt;br /&gt;
 # was the flatfielding in the reduction able to completely remove the effect of vigneting?&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
##############################&lt;br /&gt;
# Step 3: APERTURE PHOTOMETRY&lt;br /&gt;
##############################&lt;br /&gt;
&lt;br /&gt;
# make a reference.dat file - what are the x,y coordinates of the objects you want to measure?&lt;br /&gt;
# lets take three objects - a check star, a comaprison star and the target&lt;br /&gt;
&lt;br /&gt;
# Compare this&lt;br /&gt;
# http://var2.astro.cz/ETD/predict_detail.php?STARNAME=Qatar-2&amp;amp;PLANET=b&amp;amp;PER=&amp;amp;M=&lt;br /&gt;
# with the first frame&lt;br /&gt;
&lt;br /&gt;
displ Qatar2b-101_V.fit 1&lt;br /&gt;
&lt;br /&gt;
# note that the image looks flipped in the X axis (why could that be?)&lt;br /&gt;
# Do Zoom -&amp;gt; Invert X in DS9 to make life easier&lt;br /&gt;
&lt;br /&gt;
# The star with the Qatar-2b planet is the one in the middle, close to &lt;br /&gt;
# (x,y) = (1060,920)&lt;br /&gt;
# click on the star in DS9. A green circle should appear.&lt;br /&gt;
# Make sure the circle is selected (active) and go to the menu and click&lt;br /&gt;
# Region -&amp;gt; Centroid &lt;br /&gt;
# then double click the circle to see its properties&lt;br /&gt;
# you will see the center as (1062, 919)&lt;br /&gt;
&lt;br /&gt;
# Do the same for objects at (740,711) which we will take as comparison star&lt;br /&gt;
# and (1374, 1716)&lt;br /&gt;
# DONT FORGET THE DISPLAYED IMAGE IS FLIPPED IN X (coordinates are larger to the left)&lt;br /&gt;
&lt;br /&gt;
# as in the exercise with the fake data&lt;br /&gt;
# make a reference.dat file containing these x and y of three objects&lt;br /&gt;
# (no commas between x and y)&lt;br /&gt;
# copy it so that it is also a .coo file for the first frame &lt;br /&gt;
&lt;br /&gt;
!cp reference.dat Qatar2b-101_V.coo&lt;br /&gt;
&lt;br /&gt;
# check it once more&lt;br /&gt;
displ Qatar2b-101_V 1&lt;br /&gt;
tvmark 1 reference.dat mark=&amp;quot;circle&amp;quot; radii=20&lt;br /&gt;
&lt;br /&gt;
# calculate offsets using python code&lt;br /&gt;
!cp ../offsets_qphot.py .&lt;br /&gt;
!cp ../reference.dat .&lt;br /&gt;
!python offsets_qphot.py&lt;br /&gt;
&lt;br /&gt;
# when promtped answer:&lt;br /&gt;
# Enter file with the list of images to be processed: qatar.list&lt;br /&gt;
# Enter file with object x,y coordinates in the reference frame: reference.dat&lt;br /&gt;
# The code will display a plot of all the X and Y offsets. &lt;br /&gt;
&lt;br /&gt;
# Can you understand why are the X shifts continually drifting?&lt;br /&gt;
# Its the telescope tracking innacuracy!&lt;br /&gt;
# Why is there a sudden jump at frame 90 in Y shifts?&lt;br /&gt;
# Somebody adjusted the field by moving the telescope at that time!&lt;br /&gt;
# Close this plot to continue.&lt;br /&gt;
&lt;br /&gt;
# make the list of all the  .coo file&lt;br /&gt;
&lt;br /&gt;
!ls Qatar*coo &amp;gt; coolist&lt;br /&gt;
&lt;br /&gt;
# load the IRAF apphot package&lt;br /&gt;
noao &lt;br /&gt;
digiphot&lt;br /&gt;
apphot&lt;br /&gt;
&lt;br /&gt;
# set parameters of qphot which are instrument dependent&lt;br /&gt;
&lt;br /&gt;
# FITS keywords for filter, time and exposure&lt;br /&gt;
# and some instrument and data specific parameters: CCD camera gain &lt;br /&gt;
# and magnitude scale flux zeropoint (if known, or taken arbitrary setpoint)&lt;br /&gt;
# for the case of Qatar*.fit files in this exercise:&lt;br /&gt;
&lt;br /&gt;
qphot.obstime=&amp;quot;date&amp;quot;&lt;br /&gt;
qphot.exposur=&amp;quot;exptime&amp;quot;&lt;br /&gt;
qphot.zmag = 20.&lt;br /&gt;
qphot.epadu= 1.2&lt;br /&gt;
&lt;br /&gt;
# set sizes of annuli for measuring stars&lt;br /&gt;
# centering box size (qphot star will recenter the target positions)&lt;br /&gt;
# measuring aperture for star, and for sky inner radius and sky outer radius&lt;br /&gt;
&lt;br /&gt;
qphot.cbox = 5.&lt;br /&gt;
qphot.annulus=20.&lt;br /&gt;
qphot.dannulus=20.&lt;br /&gt;
qphot.aperture=10.&lt;br /&gt;
&lt;br /&gt;
qphot @qatar.list coords=@coolist interac-&lt;br /&gt;
# just hit enter when prompted, the defaults have been set in the earlier step&lt;br /&gt;
&lt;br /&gt;
# QPHOT creates output files of the type QatarXXX.fit.mag.1 &lt;br /&gt;
# It contains various measurements of relevance to the aperture photometry&lt;br /&gt;
# there is one file for every image, with three different sources measured&lt;br /&gt;
# To convert this output into something more basic, you can use&lt;br /&gt;
# IRAF txdump command - it will print out just the columns you request&lt;br /&gt;
# but it will do so for all three sources&lt;br /&gt;
&lt;br /&gt;
txdump Qatar*.mag.1 image,otime,xcenter,ycenter,mag,merr yes &amp;gt; all_measurements.dat&lt;br /&gt;
&lt;br /&gt;
# extract the three sources separately for convenience of analysis&lt;br /&gt;
# the sed commands below extract the first line and then every third, &lt;br /&gt;
# or the second and every third and so on.&lt;br /&gt;
!sed -n 'p;n;n;' all_measurements.dat &amp;gt;! target.dat&lt;br /&gt;
!sed -n 'n;p;n;' all_measurements.dat &amp;gt;! comparison.dat&lt;br /&gt;
!sed -n 'n;n;p;' all_measurements.dat &amp;gt;! check.dat&lt;br /&gt;
&lt;br /&gt;
# use your favorite plotting software to plot the difference between target and comparison&lt;br /&gt;
# overplot the total error (propagate magnitude errors in quadrature!)&lt;br /&gt;
# Here is what I got as a result qatar2b-exercise.jpeg&lt;br /&gt;
&lt;br /&gt;
# Lets check the magnitude of our check star, and the  difference between comparison and check.&lt;br /&gt;
# if everything is in order and our comparison and check stars are not variable, &lt;br /&gt;
# the difference should be constant.&lt;br /&gt;
&lt;br /&gt;
# Examine check.dat. Wait. what? Magnitudes are jumping up and down, and going to INDEF.&lt;br /&gt;
# Is there a problem? Seems like qphot could not measure anything in frame Qatar2b-122_V.fit&lt;br /&gt;
# And there is a jump in five magnitudes between 109 and 110. Smells like a crude error.&lt;br /&gt;
# Lets see what is going on.&lt;br /&gt;
&lt;br /&gt;
# delete all frames in DS9 and then&lt;br /&gt;
displ Qatar2b-101_V.fit 1&lt;br /&gt;
displ Qatar2b-110_V.fit 2&lt;br /&gt;
# blink them. Look at the positon of the chosen check star. &lt;br /&gt;
# Still dont see anything strange?&lt;br /&gt;
# how about now?&lt;br /&gt;
displ Qatar2b-120_V.fit 3&lt;br /&gt;
displ Qatar2b-130_V.fit 4&lt;br /&gt;
displ Qatar2b-140_V.fit 5&lt;br /&gt;
displ Qatar2b-150_V.fit 6&lt;br /&gt;
&lt;br /&gt;
# use TAB in DS9 to flip trough the 6 frames.&lt;br /&gt;
# IT'S MOVING! Congratulations. You just discovered an asteroid (or a new Solar System planet?)&lt;br /&gt;
# by accident. It happens. Always - always be on the lookout and check-check-doublecheck your data.&lt;br /&gt;
&lt;br /&gt;
# Do you know how to use the information from the header of the CCD image and go to&lt;br /&gt;
# Minor Planet Center Checker and find out if this is a known asteroid?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=112</id>
		<title>CCD data reduction</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=112"/>
		<updated>2023-11-23T09:04:08Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* Calibration of science frames */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic data reduction using IRAF ==&lt;br /&gt;
&lt;br /&gt;
Below is a bash script that creates lists of all images: biases, flats, darks and targets.&lt;br /&gt;
Special case of dark frames of 600sec that Milankovic generates is used&lt;br /&gt;
Last lines create ascii files with median values in flat frames that will be used&lt;br /&gt;
for their normalization.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;&lt;br /&gt;
The script creates reduce.cl IRAF script that should be run from iraf:&lt;br /&gt;
cl &amp;lt; reduce.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
rm *list&lt;br /&gt;
for frame in $(ls *fit); do&lt;br /&gt;
	filterType=$(gethead filter $frame)&lt;br /&gt;
	imageType=$(gethead imagetyp $frame)&lt;br /&gt;
	outFileName=$(echo $imageType | tr '[:upper:]' '[:lower:]')&lt;br /&gt;
	# test if DARK&lt;br /&gt;
	if [ ${imageType} = &amp;quot;DARK&amp;quot; ]; then&lt;br /&gt;
 		exptime=$(gethead exptime $frame | cut -d. -f1) &lt;br /&gt;
 		ls $frame &amp;gt;&amp;gt; ${outFileName}${exptime}&amp;quot;s&amp;quot;.list &lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${exptime}&amp;quot;s&amp;quot;.list&lt;br /&gt;
	else ls $frame &amp;gt;&amp;gt; ${outFileName}${filterType}.list&lt;br /&gt;
	fi&lt;br /&gt;
	# test if LIGHT and create additional lists&lt;br /&gt;
	if [ ${imageType} = &amp;quot;LIGHT&amp;quot; ]; then&lt;br /&gt;
	 	exptime=$(gethead exptime $frame | cut -d. -f1)&lt;br /&gt;
		echo $exptime &amp;gt;&amp;gt; exptime${filterType}.list&lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bdf&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bdf&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	 else if [ ${imageType} = &amp;quot;FLAT&amp;quot; ]; then&lt;br /&gt;
                echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
                echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;nbd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;nbd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	      fi&lt;br /&gt;
	 fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
# Create dark current corresponding to each light frame using exposure time&lt;br /&gt;
for exptime in $(ls exptime*.list); do &lt;br /&gt;
	filter=$(echo $exptime | sed -e s/exptime//g -e s/\.list//g);&lt;br /&gt;
	awk -v filter=${filter} '{print &amp;quot;dc&amp;quot;NR&amp;quot;_&amp;quot;filter&amp;quot;.fits&amp;quot;}' exptime${filter}.list  &amp;gt; dc${filter}.list&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce.cl ]; then rm reduce.cl; fi&lt;br /&gt;
echo &amp;quot;imdelete master_bias,dc_600s,dc_5s,dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bias.list master_bias comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark600s.list - master_bias @bdark600s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark5s.list - master_bias @bdark5s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark5s.list dc_5s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark600s.list dc_600s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl &lt;br /&gt;
echo &amp;quot;imarith dc_600s / 600 dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
&lt;br /&gt;
for flats in $(ls flat*list); do&lt;br /&gt;
        filterType=$(echo $flats | sed s/flat//g | cut -d. -f1)&lt;br /&gt;
        #echo $filterType&lt;br /&gt;
	echo &amp;quot;imarith @flat${filterType}.list - master_bias @bflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imarith @bflat${filterType}.list - dc_5s @bdflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imstat @bdflat${filterType}.list fields=\&amp;quot;image,midpt\&amp;quot; format- &amp;gt; norm${filterType}.txt&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Flat field normalization ==&lt;br /&gt;
&lt;br /&gt;
From terminal (bash):&lt;br /&gt;
&amp;lt;pre&amp;gt;  &lt;br /&gt;
for norm in $(ls norm*txt); do while read line; do echo $line | awk '! /^#/{print &amp;quot;imarith &amp;quot;$1&amp;quot; / &amp;quot;$2,&amp;quot;n&amp;quot;$1}'; done &amp;lt; $norm ; done &amp;gt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From terminal (IRAF):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cl &amp;lt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Calibration of science frames ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash/&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce_images.cl ]; then rm reduce_images.cl; fi&lt;br /&gt;
&lt;br /&gt;
for flat_list in $(ls nbdflat*list); do&lt;br /&gt;
        filter=$(echo ${flat_list} | sed -e s/nbdflat//g -e s/\.list//g);&lt;br /&gt;
        if [ -e light${filter}.list ]; then&lt;br /&gt;
                echo &amp;quot;imcomb @nbdflat${filter}.list master_flat_${filter} comb=med&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith @light${filter}.list - master_bias @blight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith dc_1s * @exptime${filter}.list @dc${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith @blight${filter}.list - @dc${filter}.list @bdlight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith @bdlight${filter}.list / master_flat_${filter} @bdflight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
        fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This script creates IRAF's script reduce_images.cl that should be started from IRAF's terminal. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;&lt;br /&gt;
AFTER the script is run from IRAF terminal, clean up the junk (from bash terminal):&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat blight*list bdlight*list bflat*list bdflat*list nbdflat*list bdark*list dc*.list &amp;gt; tmp_files.list&lt;br /&gt;
rm $(&amp;lt;tmp_files.list)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  BPM &amp;amp; object mask creation ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cat bpmask.cl&lt;br /&gt;
imstat dc_600s field=&amp;quot;image,mean,stddev&amp;quot; for- &amp;gt; hot.txt&lt;br /&gt;
imstat master_flat_FILTER fields=&amp;quot;image,mean&amp;quot; for- &amp;gt; cold.txt&lt;br /&gt;
cl &amp;lt; bpmask.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;gt; b) ? 1 : 0)\&amp;quot; hot&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;($2+3.*$3)*0.75}' hot.txt &amp;gt; hot.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;lt; b) ? 1 : 0)\&amp;quot; cold&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;$2*0.9}' cold.txt &amp;gt; cold.cl&lt;br /&gt;
cl &amp;lt; hot.cl&lt;br /&gt;
cl &amp;lt; cold.cl&lt;br /&gt;
# cat bpm.cl&lt;br /&gt;
imexpr &amp;quot;max(a,b)&amp;quot; bpmFILTER.pl a=hotFILTER.pl b=coldFILTER.pl&lt;br /&gt;
hedit @bdfFILTER.list BPM bpmFILTER.pl add+ ver- &lt;br /&gt;
# sed 's/FILTER/'${filter}'/g'  bpm.cl &amp;gt; dobpm.cl&lt;br /&gt;
cl &amp;lt; dobpm.cl&lt;br /&gt;
  &lt;br /&gt;
# Object masks creation&lt;br /&gt;
nproto&lt;br /&gt;
objmask @bdfFILTER.list @objbdfFILTER.list masks=&amp;quot;!BPM&amp;quot; hsig=2 lsig=2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Astrometry ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh/&lt;br /&gt;
&lt;br /&gt;
for list in $(ls bdflight*list); do&lt;br /&gt;
	while read frame; do &lt;br /&gt;
	ra=$(gethead OBJCTRA $frame | awk '{print $1&amp;quot;:&amp;quot;$2&amp;quot;:&amp;quot;$3}')&lt;br /&gt;
	dec=$(gethead OBJCTDEC $frame | awk '{print $1&amp;quot;:&amp;quot;$2&amp;quot;:&amp;quot;$3}')&lt;br /&gt;
	solve-field &amp;quot;$frame&amp;quot; --ra &amp;quot;$ra&amp;quot; --dec &amp;quot;$dec&amp;quot; --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcs&amp;quot;$frame&amp;quot; -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy --wcs bla.wcs&lt;br /&gt;
	done &amp;lt; $list&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Supersky flat ==&lt;br /&gt;
 # Creation of super sky flat, normalization to each individual image median background and final stacking&lt;br /&gt;
 # cat stat.cl&lt;br /&gt;
 real mini&lt;br /&gt;
 real sky&lt;br /&gt;
 imstat(&amp;quot;img&amp;quot;,fields=&amp;quot;min&amp;quot;,lower=INDEF,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, mini)&lt;br /&gt;
 imcalc(input=&amp;quot;img,msk&amp;quot;,output=&amp;quot;skyimage&amp;quot;,equals=&amp;quot;if(im2==0.) then im1 else &amp;quot;//mini-0.001,ver-)&lt;br /&gt;
 imstat(&amp;quot;skyimage&amp;quot;,fields=&amp;quot;midpt&amp;quot;,lower=mini-0.001,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, sky)&lt;br /&gt;
 print(&amp;quot;img&amp;quot;,&amp;quot; &amp;quot;,sky)&lt;br /&gt;
 imarith(&amp;quot;img&amp;quot;,&amp;quot;/&amp;quot;,sky,&amp;quot;norm&amp;quot;)&lt;br /&gt;
 imdelete(&amp;quot;skyimage&amp;quot;,yes)&lt;br /&gt;
 # while read line; do img=$(echo $line | awk '{print $1}'); msk=&amp;quot;obj&amp;quot;${img%.*}.pl; rsky=&amp;quot;norm&amp;quot;${img}; cat stat.cl | sed -e 's/img/'${img}'/g' \&lt;br /&gt;
 -e 's/msk/'${msk}'/g'  -e 's/norm/'${rsky}'/g'; done &amp;lt; bdf${filter}.list &amp;gt;  bla.cl&lt;br /&gt;
 cl &amp;lt; bla.cl &amp;gt; med_values.txt&lt;br /&gt;
 # ls normbdf*fit &amp;gt; norm.list&lt;br /&gt;
 imcomb @norm.list norm.fits comb=med masktype=&amp;quot;!OBJMASK&amp;quot; maskval=0&lt;br /&gt;
 # awk '{print &amp;quot;imarith norm.fits * &amp;quot;$2,&amp;quot; n&amp;quot;$1}' med_values.txt &amp;gt; donorm.cl&lt;br /&gt;
 cl &amp;lt; donorm.cl&lt;br /&gt;
 # awk '{print &amp;quot;imarith&amp;quot;,$1,&amp;quot;-&amp;quot;,&amp;quot;n&amp;quot;$1,&amp;quot;s&amp;quot;$1}' med_values.txt &amp;gt; do.cl&lt;br /&gt;
 cl &amp;lt; do.cl&lt;br /&gt;
    &lt;br /&gt;
 imcomb s@bdfFILTER.list final.fits comb=med offset=&amp;quot;wcs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Surface brightness limit ==&lt;br /&gt;
&lt;br /&gt;
 1. Calibrate the image taking non-saturated stars and not too faint stars: intercept and slope (TOPCAT with SDSS DR12 from Vizier)&lt;br /&gt;
 2. Calculate statistics inside at least 20 (empty, i.e. without objects) boxes of the size of 10&amp;quot; (for example if 1pix=0.396&amp;quot; than 10&amp;quot;~25 pix so boxes = 25 pix &amp;amp;times; 25 pix)&lt;br /&gt;
 3. Take the mean value of the standard deviation inside boxes and it's standard deviation&lt;br /&gt;
 4. Calculate SBmin and SBmax as: &lt;br /&gt;
    SBmax =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;-stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
    SBmin =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;+stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
 where &amp;lt;&amp;amp;sigma;&amp;gt; is the average standard deviation inside boxes and stdev(&amp;lt;&amp;amp;sigma;&amp;gt;) its standard deviation.&lt;br /&gt;
 5. Finally, 1 sigma surface brightness limit (SBlim) is given as:&lt;br /&gt;
    SBlim = (SBmin+SBmax)/2 +/- (SBmax-SBmin)/2&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=111</id>
		<title>CCD data reduction</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=111"/>
		<updated>2023-11-22T14:28:36Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* Calibration of science frames */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic data reduction using IRAF ==&lt;br /&gt;
&lt;br /&gt;
Below is a bash script that creates lists of all images: biases, flats, darks and targets.&lt;br /&gt;
Special case of dark frames of 600sec that Milankovic generates is used&lt;br /&gt;
Last lines create ascii files with median values in flat frames that will be used&lt;br /&gt;
for their normalization.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;&lt;br /&gt;
The script creates reduce.cl IRAF script that should be run from iraf:&lt;br /&gt;
cl &amp;lt; reduce.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
rm *list&lt;br /&gt;
for frame in $(ls *fit); do&lt;br /&gt;
	filterType=$(gethead filter $frame)&lt;br /&gt;
	imageType=$(gethead imagetyp $frame)&lt;br /&gt;
	outFileName=$(echo $imageType | tr '[:upper:]' '[:lower:]')&lt;br /&gt;
	# test if DARK&lt;br /&gt;
	if [ ${imageType} = &amp;quot;DARK&amp;quot; ]; then&lt;br /&gt;
 		exptime=$(gethead exptime $frame | cut -d. -f1) &lt;br /&gt;
 		ls $frame &amp;gt;&amp;gt; ${outFileName}${exptime}&amp;quot;s&amp;quot;.list &lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${exptime}&amp;quot;s&amp;quot;.list&lt;br /&gt;
	else ls $frame &amp;gt;&amp;gt; ${outFileName}${filterType}.list&lt;br /&gt;
	fi&lt;br /&gt;
	# test if LIGHT and create additional lists&lt;br /&gt;
	if [ ${imageType} = &amp;quot;LIGHT&amp;quot; ]; then&lt;br /&gt;
	 	exptime=$(gethead exptime $frame | cut -d. -f1)&lt;br /&gt;
		echo $exptime &amp;gt;&amp;gt; exptime${filterType}.list&lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bdf&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bdf&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	 else if [ ${imageType} = &amp;quot;FLAT&amp;quot; ]; then&lt;br /&gt;
                echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
                echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;nbd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;nbd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	      fi&lt;br /&gt;
	 fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
# Create dark current corresponding to each light frame using exposure time&lt;br /&gt;
for exptime in $(ls exptime*.list); do &lt;br /&gt;
	filter=$(echo $exptime | sed -e s/exptime//g -e s/\.list//g);&lt;br /&gt;
	awk -v filter=${filter} '{print &amp;quot;dc&amp;quot;NR&amp;quot;_&amp;quot;filter&amp;quot;.fits&amp;quot;}' exptime${filter}.list  &amp;gt; dc${filter}.list&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce.cl ]; then rm reduce.cl; fi&lt;br /&gt;
echo &amp;quot;imdelete master_bias,dc_600s,dc_5s,dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bias.list master_bias comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark600s.list - master_bias @bdark600s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark5s.list - master_bias @bdark5s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark5s.list dc_5s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark600s.list dc_600s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl &lt;br /&gt;
echo &amp;quot;imarith dc_600s / 600 dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
&lt;br /&gt;
for flats in $(ls flat*list); do&lt;br /&gt;
        filterType=$(echo $flats | sed s/flat//g | cut -d. -f1)&lt;br /&gt;
        #echo $filterType&lt;br /&gt;
	echo &amp;quot;imarith @flat${filterType}.list - master_bias @bflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imarith @bflat${filterType}.list - dc_5s @bdflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imstat @bdflat${filterType}.list fields=\&amp;quot;image,midpt\&amp;quot; format- &amp;gt; norm${filterType}.txt&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Flat field normalization ==&lt;br /&gt;
&lt;br /&gt;
From terminal (bash):&lt;br /&gt;
&amp;lt;pre&amp;gt;  &lt;br /&gt;
for norm in $(ls norm*txt); do while read line; do echo $line | awk '! /^#/{print &amp;quot;imarith &amp;quot;$1&amp;quot; / &amp;quot;$2,&amp;quot;n&amp;quot;$1}'; done &amp;lt; $norm ; done &amp;gt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From terminal (IRAF):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cl &amp;lt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Calibration of science frames ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash/&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce_images.cl ]; then rm reduce_images.cl; fi&lt;br /&gt;
&lt;br /&gt;
for flat_list in $(ls nbdflat*list); do&lt;br /&gt;
        filter=$(echo ${flat_list} | sed -e s/nbdflat//g -e s/\.list//g);&lt;br /&gt;
        if [ -e light${filter}.list ]; then&lt;br /&gt;
                echo &amp;quot;imcomb @nbdflat${filter}.list master_flat_${filter} comb=med&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith @light${filter}.list - master_bias @blight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith dc_1s * @exptime${filter}.list @dc${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith @blight${filter}.list - @dc${filter}.list @bdlight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith @bdlight${filter}.list / master_flat_${filter} @bdflight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
        fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This script creates IRAF's script reduce_images.cl that should be started from IRAF's terminal. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;&lt;br /&gt;
AFTER the script is run from IRAF terminal, clean up the junk (from bash terminal):&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat blight*list bdlight*list bflat*list bdflat*list nbdflat*list bdark*list dc*.list &amp;gt; tmp_files.list&lt;br /&gt;
while read line; do rm $line; done &amp;lt; tmp_files.list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  BPM &amp;amp; object mask creation ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cat bpmask.cl&lt;br /&gt;
imstat dc_600s field=&amp;quot;image,mean,stddev&amp;quot; for- &amp;gt; hot.txt&lt;br /&gt;
imstat master_flat_FILTER fields=&amp;quot;image,mean&amp;quot; for- &amp;gt; cold.txt&lt;br /&gt;
cl &amp;lt; bpmask.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;gt; b) ? 1 : 0)\&amp;quot; hot&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;($2+3.*$3)*0.75}' hot.txt &amp;gt; hot.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;lt; b) ? 1 : 0)\&amp;quot; cold&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;$2*0.9}' cold.txt &amp;gt; cold.cl&lt;br /&gt;
cl &amp;lt; hot.cl&lt;br /&gt;
cl &amp;lt; cold.cl&lt;br /&gt;
# cat bpm.cl&lt;br /&gt;
imexpr &amp;quot;max(a,b)&amp;quot; bpmFILTER.pl a=hotFILTER.pl b=coldFILTER.pl&lt;br /&gt;
hedit @bdfFILTER.list BPM bpmFILTER.pl add+ ver- &lt;br /&gt;
# sed 's/FILTER/'${filter}'/g'  bpm.cl &amp;gt; dobpm.cl&lt;br /&gt;
cl &amp;lt; dobpm.cl&lt;br /&gt;
  &lt;br /&gt;
# Object masks creation&lt;br /&gt;
nproto&lt;br /&gt;
objmask @bdfFILTER.list @objbdfFILTER.list masks=&amp;quot;!BPM&amp;quot; hsig=2 lsig=2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Astrometry ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh/&lt;br /&gt;
&lt;br /&gt;
for list in $(ls bdflight*list); do&lt;br /&gt;
	while read frame; do &lt;br /&gt;
	ra=$(gethead OBJCTRA $frame | awk '{print $1&amp;quot;:&amp;quot;$2&amp;quot;:&amp;quot;$3}')&lt;br /&gt;
	dec=$(gethead OBJCTDEC $frame | awk '{print $1&amp;quot;:&amp;quot;$2&amp;quot;:&amp;quot;$3}')&lt;br /&gt;
	solve-field &amp;quot;$frame&amp;quot; --ra &amp;quot;$ra&amp;quot; --dec &amp;quot;$dec&amp;quot; --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcs&amp;quot;$frame&amp;quot; -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy --wcs bla.wcs&lt;br /&gt;
	done &amp;lt; $list&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Supersky flat ==&lt;br /&gt;
 # Creation of super sky flat, normalization to each individual image median background and final stacking&lt;br /&gt;
 # cat stat.cl&lt;br /&gt;
 real mini&lt;br /&gt;
 real sky&lt;br /&gt;
 imstat(&amp;quot;img&amp;quot;,fields=&amp;quot;min&amp;quot;,lower=INDEF,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, mini)&lt;br /&gt;
 imcalc(input=&amp;quot;img,msk&amp;quot;,output=&amp;quot;skyimage&amp;quot;,equals=&amp;quot;if(im2==0.) then im1 else &amp;quot;//mini-0.001,ver-)&lt;br /&gt;
 imstat(&amp;quot;skyimage&amp;quot;,fields=&amp;quot;midpt&amp;quot;,lower=mini-0.001,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, sky)&lt;br /&gt;
 print(&amp;quot;img&amp;quot;,&amp;quot; &amp;quot;,sky)&lt;br /&gt;
 imarith(&amp;quot;img&amp;quot;,&amp;quot;/&amp;quot;,sky,&amp;quot;norm&amp;quot;)&lt;br /&gt;
 imdelete(&amp;quot;skyimage&amp;quot;,yes)&lt;br /&gt;
 # while read line; do img=$(echo $line | awk '{print $1}'); msk=&amp;quot;obj&amp;quot;${img%.*}.pl; rsky=&amp;quot;norm&amp;quot;${img}; cat stat.cl | sed -e 's/img/'${img}'/g' \&lt;br /&gt;
 -e 's/msk/'${msk}'/g'  -e 's/norm/'${rsky}'/g'; done &amp;lt; bdf${filter}.list &amp;gt;  bla.cl&lt;br /&gt;
 cl &amp;lt; bla.cl &amp;gt; med_values.txt&lt;br /&gt;
 # ls normbdf*fit &amp;gt; norm.list&lt;br /&gt;
 imcomb @norm.list norm.fits comb=med masktype=&amp;quot;!OBJMASK&amp;quot; maskval=0&lt;br /&gt;
 # awk '{print &amp;quot;imarith norm.fits * &amp;quot;$2,&amp;quot; n&amp;quot;$1}' med_values.txt &amp;gt; donorm.cl&lt;br /&gt;
 cl &amp;lt; donorm.cl&lt;br /&gt;
 # awk '{print &amp;quot;imarith&amp;quot;,$1,&amp;quot;-&amp;quot;,&amp;quot;n&amp;quot;$1,&amp;quot;s&amp;quot;$1}' med_values.txt &amp;gt; do.cl&lt;br /&gt;
 cl &amp;lt; do.cl&lt;br /&gt;
    &lt;br /&gt;
 imcomb s@bdfFILTER.list final.fits comb=med offset=&amp;quot;wcs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Surface brightness limit ==&lt;br /&gt;
&lt;br /&gt;
 1. Calibrate the image taking non-saturated stars and not too faint stars: intercept and slope (TOPCAT with SDSS DR12 from Vizier)&lt;br /&gt;
 2. Calculate statistics inside at least 20 (empty, i.e. without objects) boxes of the size of 10&amp;quot; (for example if 1pix=0.396&amp;quot; than 10&amp;quot;~25 pix so boxes = 25 pix &amp;amp;times; 25 pix)&lt;br /&gt;
 3. Take the mean value of the standard deviation inside boxes and it's standard deviation&lt;br /&gt;
 4. Calculate SBmin and SBmax as: &lt;br /&gt;
    SBmax =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;-stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
    SBmin =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;+stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
 where &amp;lt;&amp;amp;sigma;&amp;gt; is the average standard deviation inside boxes and stdev(&amp;lt;&amp;amp;sigma;&amp;gt;) its standard deviation.&lt;br /&gt;
 5. Finally, 1 sigma surface brightness limit (SBlim) is given as:&lt;br /&gt;
    SBlim = (SBmin+SBmax)/2 +/- (SBmax-SBmin)/2&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=110</id>
		<title>CCD data reduction</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=110"/>
		<updated>2023-11-22T14:22:12Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* Calibration of science frames */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic data reduction using IRAF ==&lt;br /&gt;
&lt;br /&gt;
Below is a bash script that creates lists of all images: biases, flats, darks and targets.&lt;br /&gt;
Special case of dark frames of 600sec that Milankovic generates is used&lt;br /&gt;
Last lines create ascii files with median values in flat frames that will be used&lt;br /&gt;
for their normalization.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;&lt;br /&gt;
The script creates reduce.cl IRAF script that should be run from iraf:&lt;br /&gt;
cl &amp;lt; reduce.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
rm *list&lt;br /&gt;
for frame in $(ls *fit); do&lt;br /&gt;
	filterType=$(gethead filter $frame)&lt;br /&gt;
	imageType=$(gethead imagetyp $frame)&lt;br /&gt;
	outFileName=$(echo $imageType | tr '[:upper:]' '[:lower:]')&lt;br /&gt;
	# test if DARK&lt;br /&gt;
	if [ ${imageType} = &amp;quot;DARK&amp;quot; ]; then&lt;br /&gt;
 		exptime=$(gethead exptime $frame | cut -d. -f1) &lt;br /&gt;
 		ls $frame &amp;gt;&amp;gt; ${outFileName}${exptime}&amp;quot;s&amp;quot;.list &lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${exptime}&amp;quot;s&amp;quot;.list&lt;br /&gt;
	else ls $frame &amp;gt;&amp;gt; ${outFileName}${filterType}.list&lt;br /&gt;
	fi&lt;br /&gt;
	# test if LIGHT and create additional lists&lt;br /&gt;
	if [ ${imageType} = &amp;quot;LIGHT&amp;quot; ]; then&lt;br /&gt;
	 	exptime=$(gethead exptime $frame | cut -d. -f1)&lt;br /&gt;
		echo $exptime &amp;gt;&amp;gt; exptime${filterType}.list&lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bdf&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bdf&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	 else if [ ${imageType} = &amp;quot;FLAT&amp;quot; ]; then&lt;br /&gt;
                echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
                echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;nbd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;nbd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	      fi&lt;br /&gt;
	 fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
# Create dark current corresponding to each light frame using exposure time&lt;br /&gt;
for exptime in $(ls exptime*.list); do &lt;br /&gt;
	filter=$(echo $exptime | sed -e s/exptime//g -e s/\.list//g);&lt;br /&gt;
	awk -v filter=${filter} '{print &amp;quot;dc&amp;quot;NR&amp;quot;_&amp;quot;filter&amp;quot;.fits&amp;quot;}' exptime${filter}.list  &amp;gt; dc${filter}.list&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce.cl ]; then rm reduce.cl; fi&lt;br /&gt;
echo &amp;quot;imdelete master_bias,dc_600s,dc_5s,dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bias.list master_bias comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark600s.list - master_bias @bdark600s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark5s.list - master_bias @bdark5s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark5s.list dc_5s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark600s.list dc_600s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl &lt;br /&gt;
echo &amp;quot;imarith dc_600s / 600 dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
&lt;br /&gt;
for flats in $(ls flat*list); do&lt;br /&gt;
        filterType=$(echo $flats | sed s/flat//g | cut -d. -f1)&lt;br /&gt;
        #echo $filterType&lt;br /&gt;
	echo &amp;quot;imarith @flat${filterType}.list - master_bias @bflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imarith @bflat${filterType}.list - dc_5s @bdflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imstat @bdflat${filterType}.list fields=\&amp;quot;image,midpt\&amp;quot; format- &amp;gt; norm${filterType}.txt&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Flat field normalization ==&lt;br /&gt;
&lt;br /&gt;
From terminal (bash):&lt;br /&gt;
&amp;lt;pre&amp;gt;  &lt;br /&gt;
for norm in $(ls norm*txt); do while read line; do echo $line | awk '! /^#/{print &amp;quot;imarith &amp;quot;$1&amp;quot; / &amp;quot;$2,&amp;quot;n&amp;quot;$1}'; done &amp;lt; $norm ; done &amp;gt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From terminal (IRAF):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cl &amp;lt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Calibration of science frames ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash/&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce_images.cl ]; then rm reduce_images.cl; fi&lt;br /&gt;
&lt;br /&gt;
for flat_list in $(ls nbdflat*list); do&lt;br /&gt;
        filter=$(echo ${flat_list} | sed -e s/nbdflat//g -e s/\.list//g);&lt;br /&gt;
        if [ -e light${filter} ]; then&lt;br /&gt;
                echo &amp;quot;imcomb @nbdflat${filter}.list master_flat_${filter} comb=med&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith @light${filter}.list - master_bias @blight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith dc_1s * @exptime${filter}.list @dc${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith @blight${filter}.list - @dc${filter}.list @bdlight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
                echo &amp;quot;imarith @bdlight${filter}.list / master_flat_${filter} @bdflight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
        fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This script creates IRAF's script reduce_images.cl that should be started from IRAF's terminal. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;&lt;br /&gt;
AFTER the script is run from IRAF terminal, clean up the junk (from bash terminal):&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat blight*list bdlight*list bflat*list bdflat*list nbdflat*list bdark*list dc*.list &amp;gt; tmp_files.list&lt;br /&gt;
while read line; do rm $line; done &amp;lt; tmp_files.list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  BPM &amp;amp; object mask creation ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cat bpmask.cl&lt;br /&gt;
imstat dc_600s field=&amp;quot;image,mean,stddev&amp;quot; for- &amp;gt; hot.txt&lt;br /&gt;
imstat master_flat_FILTER fields=&amp;quot;image,mean&amp;quot; for- &amp;gt; cold.txt&lt;br /&gt;
cl &amp;lt; bpmask.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;gt; b) ? 1 : 0)\&amp;quot; hot&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;($2+3.*$3)*0.75}' hot.txt &amp;gt; hot.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;lt; b) ? 1 : 0)\&amp;quot; cold&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;$2*0.9}' cold.txt &amp;gt; cold.cl&lt;br /&gt;
cl &amp;lt; hot.cl&lt;br /&gt;
cl &amp;lt; cold.cl&lt;br /&gt;
# cat bpm.cl&lt;br /&gt;
imexpr &amp;quot;max(a,b)&amp;quot; bpmFILTER.pl a=hotFILTER.pl b=coldFILTER.pl&lt;br /&gt;
hedit @bdfFILTER.list BPM bpmFILTER.pl add+ ver- &lt;br /&gt;
# sed 's/FILTER/'${filter}'/g'  bpm.cl &amp;gt; dobpm.cl&lt;br /&gt;
cl &amp;lt; dobpm.cl&lt;br /&gt;
  &lt;br /&gt;
# Object masks creation&lt;br /&gt;
nproto&lt;br /&gt;
objmask @bdfFILTER.list @objbdfFILTER.list masks=&amp;quot;!BPM&amp;quot; hsig=2 lsig=2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Astrometry ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh/&lt;br /&gt;
&lt;br /&gt;
for list in $(ls bdflight*list); do&lt;br /&gt;
	while read frame; do &lt;br /&gt;
	ra=$(gethead OBJCTRA $frame | awk '{print $1&amp;quot;:&amp;quot;$2&amp;quot;:&amp;quot;$3}')&lt;br /&gt;
	dec=$(gethead OBJCTDEC $frame | awk '{print $1&amp;quot;:&amp;quot;$2&amp;quot;:&amp;quot;$3}')&lt;br /&gt;
	solve-field &amp;quot;$frame&amp;quot; --ra &amp;quot;$ra&amp;quot; --dec &amp;quot;$dec&amp;quot; --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcs&amp;quot;$frame&amp;quot; -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy --wcs bla.wcs&lt;br /&gt;
	done &amp;lt; $list&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Supersky flat ==&lt;br /&gt;
 # Creation of super sky flat, normalization to each individual image median background and final stacking&lt;br /&gt;
 # cat stat.cl&lt;br /&gt;
 real mini&lt;br /&gt;
 real sky&lt;br /&gt;
 imstat(&amp;quot;img&amp;quot;,fields=&amp;quot;min&amp;quot;,lower=INDEF,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, mini)&lt;br /&gt;
 imcalc(input=&amp;quot;img,msk&amp;quot;,output=&amp;quot;skyimage&amp;quot;,equals=&amp;quot;if(im2==0.) then im1 else &amp;quot;//mini-0.001,ver-)&lt;br /&gt;
 imstat(&amp;quot;skyimage&amp;quot;,fields=&amp;quot;midpt&amp;quot;,lower=mini-0.001,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, sky)&lt;br /&gt;
 print(&amp;quot;img&amp;quot;,&amp;quot; &amp;quot;,sky)&lt;br /&gt;
 imarith(&amp;quot;img&amp;quot;,&amp;quot;/&amp;quot;,sky,&amp;quot;norm&amp;quot;)&lt;br /&gt;
 imdelete(&amp;quot;skyimage&amp;quot;,yes)&lt;br /&gt;
 # while read line; do img=$(echo $line | awk '{print $1}'); msk=&amp;quot;obj&amp;quot;${img%.*}.pl; rsky=&amp;quot;norm&amp;quot;${img}; cat stat.cl | sed -e 's/img/'${img}'/g' \&lt;br /&gt;
 -e 's/msk/'${msk}'/g'  -e 's/norm/'${rsky}'/g'; done &amp;lt; bdf${filter}.list &amp;gt;  bla.cl&lt;br /&gt;
 cl &amp;lt; bla.cl &amp;gt; med_values.txt&lt;br /&gt;
 # ls normbdf*fit &amp;gt; norm.list&lt;br /&gt;
 imcomb @norm.list norm.fits comb=med masktype=&amp;quot;!OBJMASK&amp;quot; maskval=0&lt;br /&gt;
 # awk '{print &amp;quot;imarith norm.fits * &amp;quot;$2,&amp;quot; n&amp;quot;$1}' med_values.txt &amp;gt; donorm.cl&lt;br /&gt;
 cl &amp;lt; donorm.cl&lt;br /&gt;
 # awk '{print &amp;quot;imarith&amp;quot;,$1,&amp;quot;-&amp;quot;,&amp;quot;n&amp;quot;$1,&amp;quot;s&amp;quot;$1}' med_values.txt &amp;gt; do.cl&lt;br /&gt;
 cl &amp;lt; do.cl&lt;br /&gt;
    &lt;br /&gt;
 imcomb s@bdfFILTER.list final.fits comb=med offset=&amp;quot;wcs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Surface brightness limit ==&lt;br /&gt;
&lt;br /&gt;
 1. Calibrate the image taking non-saturated stars and not too faint stars: intercept and slope (TOPCAT with SDSS DR12 from Vizier)&lt;br /&gt;
 2. Calculate statistics inside at least 20 (empty, i.e. without objects) boxes of the size of 10&amp;quot; (for example if 1pix=0.396&amp;quot; than 10&amp;quot;~25 pix so boxes = 25 pix &amp;amp;times; 25 pix)&lt;br /&gt;
 3. Take the mean value of the standard deviation inside boxes and it's standard deviation&lt;br /&gt;
 4. Calculate SBmin and SBmax as: &lt;br /&gt;
    SBmax =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;-stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
    SBmin =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;+stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
 where &amp;lt;&amp;amp;sigma;&amp;gt; is the average standard deviation inside boxes and stdev(&amp;lt;&amp;amp;sigma;&amp;gt;) its standard deviation.&lt;br /&gt;
 5. Finally, 1 sigma surface brightness limit (SBlim) is given as:&lt;br /&gt;
    SBlim = (SBmin+SBmax)/2 +/- (SBmax-SBmin)/2&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=109</id>
		<title>CCD data reduction</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=109"/>
		<updated>2023-11-22T14:08:54Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* Calibration of science frames */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic data reduction using IRAF ==&lt;br /&gt;
&lt;br /&gt;
Below is a bash script that creates lists of all images: biases, flats, darks and targets.&lt;br /&gt;
Special case of dark frames of 600sec that Milankovic generates is used&lt;br /&gt;
Last lines create ascii files with median values in flat frames that will be used&lt;br /&gt;
for their normalization.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;&lt;br /&gt;
The script creates reduce.cl IRAF script that should be run from iraf:&lt;br /&gt;
cl &amp;lt; reduce.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
rm *list&lt;br /&gt;
for frame in $(ls *fit); do&lt;br /&gt;
	filterType=$(gethead filter $frame)&lt;br /&gt;
	imageType=$(gethead imagetyp $frame)&lt;br /&gt;
	outFileName=$(echo $imageType | tr '[:upper:]' '[:lower:]')&lt;br /&gt;
	# test if DARK&lt;br /&gt;
	if [ ${imageType} = &amp;quot;DARK&amp;quot; ]; then&lt;br /&gt;
 		exptime=$(gethead exptime $frame | cut -d. -f1) &lt;br /&gt;
 		ls $frame &amp;gt;&amp;gt; ${outFileName}${exptime}&amp;quot;s&amp;quot;.list &lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${exptime}&amp;quot;s&amp;quot;.list&lt;br /&gt;
	else ls $frame &amp;gt;&amp;gt; ${outFileName}${filterType}.list&lt;br /&gt;
	fi&lt;br /&gt;
	# test if LIGHT and create additional lists&lt;br /&gt;
	if [ ${imageType} = &amp;quot;LIGHT&amp;quot; ]; then&lt;br /&gt;
	 	exptime=$(gethead exptime $frame | cut -d. -f1)&lt;br /&gt;
		echo $exptime &amp;gt;&amp;gt; exptime${filterType}.list&lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bdf&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bdf&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	 else if [ ${imageType} = &amp;quot;FLAT&amp;quot; ]; then&lt;br /&gt;
                echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
                echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;nbd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;nbd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	      fi&lt;br /&gt;
	 fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
# Create dark current corresponding to each light frame using exposure time&lt;br /&gt;
for exptime in $(ls exptime*.list); do &lt;br /&gt;
	filter=$(echo $exptime | sed -e s/exptime//g -e s/\.list//g);&lt;br /&gt;
	awk -v filter=${filter} '{print &amp;quot;dc&amp;quot;NR&amp;quot;_&amp;quot;filter&amp;quot;.fits&amp;quot;}' exptime${filter}.list  &amp;gt; dc${filter}.list&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce.cl ]; then rm reduce.cl; fi&lt;br /&gt;
echo &amp;quot;imdelete master_bias,dc_600s,dc_5s,dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bias.list master_bias comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark600s.list - master_bias @bdark600s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark5s.list - master_bias @bdark5s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark5s.list dc_5s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark600s.list dc_600s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl &lt;br /&gt;
echo &amp;quot;imarith dc_600s / 600 dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
&lt;br /&gt;
for flats in $(ls flat*list); do&lt;br /&gt;
        filterType=$(echo $flats | sed s/flat//g | cut -d. -f1)&lt;br /&gt;
        #echo $filterType&lt;br /&gt;
	echo &amp;quot;imarith @flat${filterType}.list - master_bias @bflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imarith @bflat${filterType}.list - dc_5s @bdflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imstat @bdflat${filterType}.list fields=\&amp;quot;image,midpt\&amp;quot; format- &amp;gt; norm${filterType}.txt&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Flat field normalization ==&lt;br /&gt;
&lt;br /&gt;
From terminal (bash):&lt;br /&gt;
&amp;lt;pre&amp;gt;  &lt;br /&gt;
for norm in $(ls norm*txt); do while read line; do echo $line | awk '! /^#/{print &amp;quot;imarith &amp;quot;$1&amp;quot; / &amp;quot;$2,&amp;quot;n&amp;quot;$1}'; done &amp;lt; $norm ; done &amp;gt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From terminal (IRAF):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cl &amp;lt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Calibration of science frames ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash/&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce_images.cl ]; then rm reduce_images.cl; fi&lt;br /&gt;
&lt;br /&gt;
for flat_list in $(ls nbdflat*list); do&lt;br /&gt;
	filter=$(echo ${flat_list} | sed -e s/nbdflat//g -e s/\.list//g);&lt;br /&gt;
	echo &amp;quot;imcomb @nbdflat${filter}.list master_flat_${filter} comb=med&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
	echo &amp;quot;imarith @light${filter}.list - master_bias @blight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
	echo &amp;quot;imarith dc_1s * @exptime${filter}.list @dc${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl	&lt;br /&gt;
	echo &amp;quot;imarith @blight${filter}.list - @dc${filter}.list @bdlight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
	echo &amp;quot;imarith @bdlight${filter}.list / master_flat_${filter} @bdflight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This script creates IRAF's script reduce_images.cl that should be started from IRAF's terminal. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;&lt;br /&gt;
AFTER the script is run from IRAF terminal, clean up the junk (from bash terminal):&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat blight*list bdlight*list bflat*list bdflat*list nbdflat*list bdark*list dc*.list &amp;gt; tmp_files.list&lt;br /&gt;
while read line; do rm $line; done &amp;lt; tmp_files.list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  BPM &amp;amp; object mask creation ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cat bpmask.cl&lt;br /&gt;
imstat dc_600s field=&amp;quot;image,mean,stddev&amp;quot; for- &amp;gt; hot.txt&lt;br /&gt;
imstat master_flat_FILTER fields=&amp;quot;image,mean&amp;quot; for- &amp;gt; cold.txt&lt;br /&gt;
cl &amp;lt; bpmask.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;gt; b) ? 1 : 0)\&amp;quot; hot&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;($2+3.*$3)*0.75}' hot.txt &amp;gt; hot.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;lt; b) ? 1 : 0)\&amp;quot; cold&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;$2*0.9}' cold.txt &amp;gt; cold.cl&lt;br /&gt;
cl &amp;lt; hot.cl&lt;br /&gt;
cl &amp;lt; cold.cl&lt;br /&gt;
# cat bpm.cl&lt;br /&gt;
imexpr &amp;quot;max(a,b)&amp;quot; bpmFILTER.pl a=hotFILTER.pl b=coldFILTER.pl&lt;br /&gt;
hedit @bdfFILTER.list BPM bpmFILTER.pl add+ ver- &lt;br /&gt;
# sed 's/FILTER/'${filter}'/g'  bpm.cl &amp;gt; dobpm.cl&lt;br /&gt;
cl &amp;lt; dobpm.cl&lt;br /&gt;
  &lt;br /&gt;
# Object masks creation&lt;br /&gt;
nproto&lt;br /&gt;
objmask @bdfFILTER.list @objbdfFILTER.list masks=&amp;quot;!BPM&amp;quot; hsig=2 lsig=2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Astrometry ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh/&lt;br /&gt;
&lt;br /&gt;
for list in $(ls bdflight*list); do&lt;br /&gt;
	while read frame; do &lt;br /&gt;
	ra=$(gethead OBJCTRA $frame | awk '{print $1&amp;quot;:&amp;quot;$2&amp;quot;:&amp;quot;$3}')&lt;br /&gt;
	dec=$(gethead OBJCTDEC $frame | awk '{print $1&amp;quot;:&amp;quot;$2&amp;quot;:&amp;quot;$3}')&lt;br /&gt;
	solve-field &amp;quot;$frame&amp;quot; --ra &amp;quot;$ra&amp;quot; --dec &amp;quot;$dec&amp;quot; --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcs&amp;quot;$frame&amp;quot; -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy --wcs bla.wcs&lt;br /&gt;
	done &amp;lt; $list&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Supersky flat ==&lt;br /&gt;
 # Creation of super sky flat, normalization to each individual image median background and final stacking&lt;br /&gt;
 # cat stat.cl&lt;br /&gt;
 real mini&lt;br /&gt;
 real sky&lt;br /&gt;
 imstat(&amp;quot;img&amp;quot;,fields=&amp;quot;min&amp;quot;,lower=INDEF,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, mini)&lt;br /&gt;
 imcalc(input=&amp;quot;img,msk&amp;quot;,output=&amp;quot;skyimage&amp;quot;,equals=&amp;quot;if(im2==0.) then im1 else &amp;quot;//mini-0.001,ver-)&lt;br /&gt;
 imstat(&amp;quot;skyimage&amp;quot;,fields=&amp;quot;midpt&amp;quot;,lower=mini-0.001,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, sky)&lt;br /&gt;
 print(&amp;quot;img&amp;quot;,&amp;quot; &amp;quot;,sky)&lt;br /&gt;
 imarith(&amp;quot;img&amp;quot;,&amp;quot;/&amp;quot;,sky,&amp;quot;norm&amp;quot;)&lt;br /&gt;
 imdelete(&amp;quot;skyimage&amp;quot;,yes)&lt;br /&gt;
 # while read line; do img=$(echo $line | awk '{print $1}'); msk=&amp;quot;obj&amp;quot;${img%.*}.pl; rsky=&amp;quot;norm&amp;quot;${img}; cat stat.cl | sed -e 's/img/'${img}'/g' \&lt;br /&gt;
 -e 's/msk/'${msk}'/g'  -e 's/norm/'${rsky}'/g'; done &amp;lt; bdf${filter}.list &amp;gt;  bla.cl&lt;br /&gt;
 cl &amp;lt; bla.cl &amp;gt; med_values.txt&lt;br /&gt;
 # ls normbdf*fit &amp;gt; norm.list&lt;br /&gt;
 imcomb @norm.list norm.fits comb=med masktype=&amp;quot;!OBJMASK&amp;quot; maskval=0&lt;br /&gt;
 # awk '{print &amp;quot;imarith norm.fits * &amp;quot;$2,&amp;quot; n&amp;quot;$1}' med_values.txt &amp;gt; donorm.cl&lt;br /&gt;
 cl &amp;lt; donorm.cl&lt;br /&gt;
 # awk '{print &amp;quot;imarith&amp;quot;,$1,&amp;quot;-&amp;quot;,&amp;quot;n&amp;quot;$1,&amp;quot;s&amp;quot;$1}' med_values.txt &amp;gt; do.cl&lt;br /&gt;
 cl &amp;lt; do.cl&lt;br /&gt;
    &lt;br /&gt;
 imcomb s@bdfFILTER.list final.fits comb=med offset=&amp;quot;wcs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Surface brightness limit ==&lt;br /&gt;
&lt;br /&gt;
 1. Calibrate the image taking non-saturated stars and not too faint stars: intercept and slope (TOPCAT with SDSS DR12 from Vizier)&lt;br /&gt;
 2. Calculate statistics inside at least 20 (empty, i.e. without objects) boxes of the size of 10&amp;quot; (for example if 1pix=0.396&amp;quot; than 10&amp;quot;~25 pix so boxes = 25 pix &amp;amp;times; 25 pix)&lt;br /&gt;
 3. Take the mean value of the standard deviation inside boxes and it's standard deviation&lt;br /&gt;
 4. Calculate SBmin and SBmax as: &lt;br /&gt;
    SBmax =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;-stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
    SBmin =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;+stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
 where &amp;lt;&amp;amp;sigma;&amp;gt; is the average standard deviation inside boxes and stdev(&amp;lt;&amp;amp;sigma;&amp;gt;) its standard deviation.&lt;br /&gt;
 5. Finally, 1 sigma surface brightness limit (SBlim) is given as:&lt;br /&gt;
    SBlim = (SBmin+SBmax)/2 +/- (SBmax-SBmin)/2&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=108</id>
		<title>CCD data reduction</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=108"/>
		<updated>2023-11-22T14:06:37Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* Calibration of science frames */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic data reduction using IRAF ==&lt;br /&gt;
&lt;br /&gt;
Below is a bash script that creates lists of all images: biases, flats, darks and targets.&lt;br /&gt;
Special case of dark frames of 600sec that Milankovic generates is used&lt;br /&gt;
Last lines create ascii files with median values in flat frames that will be used&lt;br /&gt;
for their normalization.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;&lt;br /&gt;
The script creates reduce.cl IRAF script that should be run from iraf:&lt;br /&gt;
cl &amp;lt; reduce.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
rm *list&lt;br /&gt;
for frame in $(ls *fit); do&lt;br /&gt;
	filterType=$(gethead filter $frame)&lt;br /&gt;
	imageType=$(gethead imagetyp $frame)&lt;br /&gt;
	outFileName=$(echo $imageType | tr '[:upper:]' '[:lower:]')&lt;br /&gt;
	# test if DARK&lt;br /&gt;
	if [ ${imageType} = &amp;quot;DARK&amp;quot; ]; then&lt;br /&gt;
 		exptime=$(gethead exptime $frame | cut -d. -f1) &lt;br /&gt;
 		ls $frame &amp;gt;&amp;gt; ${outFileName}${exptime}&amp;quot;s&amp;quot;.list &lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${exptime}&amp;quot;s&amp;quot;.list&lt;br /&gt;
	else ls $frame &amp;gt;&amp;gt; ${outFileName}${filterType}.list&lt;br /&gt;
	fi&lt;br /&gt;
	# test if LIGHT and create additional lists&lt;br /&gt;
	if [ ${imageType} = &amp;quot;LIGHT&amp;quot; ]; then&lt;br /&gt;
	 	exptime=$(gethead exptime $frame | cut -d. -f1)&lt;br /&gt;
		echo $exptime &amp;gt;&amp;gt; exptime${filterType}.list&lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bdf&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bdf&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	 else if [ ${imageType} = &amp;quot;FLAT&amp;quot; ]; then&lt;br /&gt;
                echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
                echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;nbd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;nbd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	      fi&lt;br /&gt;
	 fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
# Create dark current corresponding to each light frame using exposure time&lt;br /&gt;
for exptime in $(ls exptime*.list); do &lt;br /&gt;
	filter=$(echo $exptime | sed -e s/exptime//g -e s/\.list//g);&lt;br /&gt;
	awk -v filter=${filter} '{print &amp;quot;dc&amp;quot;NR&amp;quot;_&amp;quot;filter&amp;quot;.fits&amp;quot;}' exptime${filter}.list  &amp;gt; dc${filter}.list&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce.cl ]; then rm reduce.cl; fi&lt;br /&gt;
echo &amp;quot;imdelete master_bias,dc_600s,dc_5s,dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bias.list master_bias comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark600s.list - master_bias @bdark600s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark5s.list - master_bias @bdark5s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark5s.list dc_5s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark600s.list dc_600s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl &lt;br /&gt;
echo &amp;quot;imarith dc_600s / 600 dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
&lt;br /&gt;
for flats in $(ls flat*list); do&lt;br /&gt;
        filterType=$(echo $flats | sed s/flat//g | cut -d. -f1)&lt;br /&gt;
        #echo $filterType&lt;br /&gt;
	echo &amp;quot;imarith @flat${filterType}.list - master_bias @bflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imarith @bflat${filterType}.list - dc_5s @bdflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imstat @bdflat${filterType}.list fields=\&amp;quot;image,midpt\&amp;quot; format- &amp;gt; norm${filterType}.txt&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Flat field normalization ==&lt;br /&gt;
&lt;br /&gt;
From terminal (bash):&lt;br /&gt;
&amp;lt;pre&amp;gt;  &lt;br /&gt;
for norm in $(ls norm*txt); do while read line; do echo $line | awk '! /^#/{print &amp;quot;imarith &amp;quot;$1&amp;quot; / &amp;quot;$2,&amp;quot;n&amp;quot;$1}'; done &amp;lt; $norm ; done &amp;gt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From terminal (IRAF):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cl &amp;lt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Calibration of science frames ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash/&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce_images.cl ]; then rm reduce_images.cl; fi&lt;br /&gt;
&lt;br /&gt;
for flat_list in $(ls nbdflat*list); do&lt;br /&gt;
	filter=$(echo ${flat_list} | sed -e s/nbdflat//g -e s/\.list//g);&lt;br /&gt;
	echo &amp;quot;imcomb @nbdflat${filter}.list master_flat_${filter} comb=med&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
	echo &amp;quot;imarith @light${filter}.list - master_bias @blight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
	echo &amp;quot;imarith dc_1s * @exptime${filter}.list @dc${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl	&lt;br /&gt;
	echo &amp;quot;imarith @blight${filter}.list - @dc${filter}.list @bdlight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
	echo &amp;quot;imarith @bdlight${filter}.list / master_flat_${filter} @bdflight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This script creates IRAF's script reduce_images.cl that should be started from IRAF's terminal. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;&lt;br /&gt;
AFTER the script is run from IRAF terminal, clean up the junk:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat blight*list bdlight*list bflat*list bdflat*list nbdflat*list bdark*list dc*.list &amp;gt; tmp_files.list&lt;br /&gt;
while read line; do rm $line; done &amp;lt; tmp_files.list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  BPM &amp;amp; object mask creation ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cat bpmask.cl&lt;br /&gt;
imstat dc_600s field=&amp;quot;image,mean,stddev&amp;quot; for- &amp;gt; hot.txt&lt;br /&gt;
imstat master_flat_FILTER fields=&amp;quot;image,mean&amp;quot; for- &amp;gt; cold.txt&lt;br /&gt;
cl &amp;lt; bpmask.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;gt; b) ? 1 : 0)\&amp;quot; hot&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;($2+3.*$3)*0.75}' hot.txt &amp;gt; hot.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;lt; b) ? 1 : 0)\&amp;quot; cold&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;$2*0.9}' cold.txt &amp;gt; cold.cl&lt;br /&gt;
cl &amp;lt; hot.cl&lt;br /&gt;
cl &amp;lt; cold.cl&lt;br /&gt;
# cat bpm.cl&lt;br /&gt;
imexpr &amp;quot;max(a,b)&amp;quot; bpmFILTER.pl a=hotFILTER.pl b=coldFILTER.pl&lt;br /&gt;
hedit @bdfFILTER.list BPM bpmFILTER.pl add+ ver- &lt;br /&gt;
# sed 's/FILTER/'${filter}'/g'  bpm.cl &amp;gt; dobpm.cl&lt;br /&gt;
cl &amp;lt; dobpm.cl&lt;br /&gt;
  &lt;br /&gt;
# Object masks creation&lt;br /&gt;
nproto&lt;br /&gt;
objmask @bdfFILTER.list @objbdfFILTER.list masks=&amp;quot;!BPM&amp;quot; hsig=2 lsig=2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Astrometry ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh/&lt;br /&gt;
&lt;br /&gt;
for list in $(ls bdflight*list); do&lt;br /&gt;
	while read frame; do &lt;br /&gt;
	ra=$(gethead OBJCTRA $frame | awk '{print $1&amp;quot;:&amp;quot;$2&amp;quot;:&amp;quot;$3}')&lt;br /&gt;
	dec=$(gethead OBJCTDEC $frame | awk '{print $1&amp;quot;:&amp;quot;$2&amp;quot;:&amp;quot;$3}')&lt;br /&gt;
	solve-field &amp;quot;$frame&amp;quot; --ra &amp;quot;$ra&amp;quot; --dec &amp;quot;$dec&amp;quot; --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcs&amp;quot;$frame&amp;quot; -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy --wcs bla.wcs&lt;br /&gt;
	done &amp;lt; $list&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Supersky flat ==&lt;br /&gt;
 # Creation of super sky flat, normalization to each individual image median background and final stacking&lt;br /&gt;
 # cat stat.cl&lt;br /&gt;
 real mini&lt;br /&gt;
 real sky&lt;br /&gt;
 imstat(&amp;quot;img&amp;quot;,fields=&amp;quot;min&amp;quot;,lower=INDEF,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, mini)&lt;br /&gt;
 imcalc(input=&amp;quot;img,msk&amp;quot;,output=&amp;quot;skyimage&amp;quot;,equals=&amp;quot;if(im2==0.) then im1 else &amp;quot;//mini-0.001,ver-)&lt;br /&gt;
 imstat(&amp;quot;skyimage&amp;quot;,fields=&amp;quot;midpt&amp;quot;,lower=mini-0.001,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, sky)&lt;br /&gt;
 print(&amp;quot;img&amp;quot;,&amp;quot; &amp;quot;,sky)&lt;br /&gt;
 imarith(&amp;quot;img&amp;quot;,&amp;quot;/&amp;quot;,sky,&amp;quot;norm&amp;quot;)&lt;br /&gt;
 imdelete(&amp;quot;skyimage&amp;quot;,yes)&lt;br /&gt;
 # while read line; do img=$(echo $line | awk '{print $1}'); msk=&amp;quot;obj&amp;quot;${img%.*}.pl; rsky=&amp;quot;norm&amp;quot;${img}; cat stat.cl | sed -e 's/img/'${img}'/g' \&lt;br /&gt;
 -e 's/msk/'${msk}'/g'  -e 's/norm/'${rsky}'/g'; done &amp;lt; bdf${filter}.list &amp;gt;  bla.cl&lt;br /&gt;
 cl &amp;lt; bla.cl &amp;gt; med_values.txt&lt;br /&gt;
 # ls normbdf*fit &amp;gt; norm.list&lt;br /&gt;
 imcomb @norm.list norm.fits comb=med masktype=&amp;quot;!OBJMASK&amp;quot; maskval=0&lt;br /&gt;
 # awk '{print &amp;quot;imarith norm.fits * &amp;quot;$2,&amp;quot; n&amp;quot;$1}' med_values.txt &amp;gt; donorm.cl&lt;br /&gt;
 cl &amp;lt; donorm.cl&lt;br /&gt;
 # awk '{print &amp;quot;imarith&amp;quot;,$1,&amp;quot;-&amp;quot;,&amp;quot;n&amp;quot;$1,&amp;quot;s&amp;quot;$1}' med_values.txt &amp;gt; do.cl&lt;br /&gt;
 cl &amp;lt; do.cl&lt;br /&gt;
    &lt;br /&gt;
 imcomb s@bdfFILTER.list final.fits comb=med offset=&amp;quot;wcs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Surface brightness limit ==&lt;br /&gt;
&lt;br /&gt;
 1. Calibrate the image taking non-saturated stars and not too faint stars: intercept and slope (TOPCAT with SDSS DR12 from Vizier)&lt;br /&gt;
 2. Calculate statistics inside at least 20 (empty, i.e. without objects) boxes of the size of 10&amp;quot; (for example if 1pix=0.396&amp;quot; than 10&amp;quot;~25 pix so boxes = 25 pix &amp;amp;times; 25 pix)&lt;br /&gt;
 3. Take the mean value of the standard deviation inside boxes and it's standard deviation&lt;br /&gt;
 4. Calculate SBmin and SBmax as: &lt;br /&gt;
    SBmax =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;-stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
    SBmin =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;+stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
 where &amp;lt;&amp;amp;sigma;&amp;gt; is the average standard deviation inside boxes and stdev(&amp;lt;&amp;amp;sigma;&amp;gt;) its standard deviation.&lt;br /&gt;
 5. Finally, 1 sigma surface brightness limit (SBlim) is given as:&lt;br /&gt;
    SBlim = (SBmin+SBmax)/2 +/- (SBmax-SBmin)/2&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=107</id>
		<title>CCD data reduction</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=107"/>
		<updated>2023-11-22T14:05:20Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* Calibration of science frames */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic data reduction using IRAF ==&lt;br /&gt;
&lt;br /&gt;
Below is a bash script that creates lists of all images: biases, flats, darks and targets.&lt;br /&gt;
Special case of dark frames of 600sec that Milankovic generates is used&lt;br /&gt;
Last lines create ascii files with median values in flat frames that will be used&lt;br /&gt;
for their normalization.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;&lt;br /&gt;
The script creates reduce.cl IRAF script that should be run from iraf:&lt;br /&gt;
cl &amp;lt; reduce.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
rm *list&lt;br /&gt;
for frame in $(ls *fit); do&lt;br /&gt;
	filterType=$(gethead filter $frame)&lt;br /&gt;
	imageType=$(gethead imagetyp $frame)&lt;br /&gt;
	outFileName=$(echo $imageType | tr '[:upper:]' '[:lower:]')&lt;br /&gt;
	# test if DARK&lt;br /&gt;
	if [ ${imageType} = &amp;quot;DARK&amp;quot; ]; then&lt;br /&gt;
 		exptime=$(gethead exptime $frame | cut -d. -f1) &lt;br /&gt;
 		ls $frame &amp;gt;&amp;gt; ${outFileName}${exptime}&amp;quot;s&amp;quot;.list &lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${exptime}&amp;quot;s&amp;quot;.list&lt;br /&gt;
	else ls $frame &amp;gt;&amp;gt; ${outFileName}${filterType}.list&lt;br /&gt;
	fi&lt;br /&gt;
	# test if LIGHT and create additional lists&lt;br /&gt;
	if [ ${imageType} = &amp;quot;LIGHT&amp;quot; ]; then&lt;br /&gt;
	 	exptime=$(gethead exptime $frame | cut -d. -f1)&lt;br /&gt;
		echo $exptime &amp;gt;&amp;gt; exptime${filterType}.list&lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bdf&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bdf&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	 else if [ ${imageType} = &amp;quot;FLAT&amp;quot; ]; then&lt;br /&gt;
                echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
                echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;nbd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;nbd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	      fi&lt;br /&gt;
	 fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
# Create dark current corresponding to each light frame using exposure time&lt;br /&gt;
for exptime in $(ls exptime*.list); do &lt;br /&gt;
	filter=$(echo $exptime | sed -e s/exptime//g -e s/\.list//g);&lt;br /&gt;
	awk -v filter=${filter} '{print &amp;quot;dc&amp;quot;NR&amp;quot;_&amp;quot;filter&amp;quot;.fits&amp;quot;}' exptime${filter}.list  &amp;gt; dc${filter}.list&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce.cl ]; then rm reduce.cl; fi&lt;br /&gt;
echo &amp;quot;imdelete master_bias,dc_600s,dc_5s,dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bias.list master_bias comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark600s.list - master_bias @bdark600s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark5s.list - master_bias @bdark5s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark5s.list dc_5s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark600s.list dc_600s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl &lt;br /&gt;
echo &amp;quot;imarith dc_600s / 600 dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
&lt;br /&gt;
for flats in $(ls flat*list); do&lt;br /&gt;
        filterType=$(echo $flats | sed s/flat//g | cut -d. -f1)&lt;br /&gt;
        #echo $filterType&lt;br /&gt;
	echo &amp;quot;imarith @flat${filterType}.list - master_bias @bflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imarith @bflat${filterType}.list - dc_5s @bdflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imstat @bdflat${filterType}.list fields=\&amp;quot;image,midpt\&amp;quot; format- &amp;gt; norm${filterType}.txt&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Flat field normalization ==&lt;br /&gt;
&lt;br /&gt;
From terminal (bash):&lt;br /&gt;
&amp;lt;pre&amp;gt;  &lt;br /&gt;
for norm in $(ls norm*txt); do while read line; do echo $line | awk '! /^#/{print &amp;quot;imarith &amp;quot;$1&amp;quot; / &amp;quot;$2,&amp;quot;n&amp;quot;$1}'; done &amp;lt; $norm ; done &amp;gt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From terminal (IRAF):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cl &amp;lt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Calibration of science frames ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash/&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce_images.cl ]; then rm reduce_images.cl; fi&lt;br /&gt;
&lt;br /&gt;
for flat_list in $(ls nbdflat*list); do&lt;br /&gt;
	filter=$(echo ${flat_list} | sed -e s/nbdflat//g -e s/\.list//g);&lt;br /&gt;
	echo &amp;quot;imcomb @nbdflat${filter}.list master_flat_${filter} comb=med&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
	echo &amp;quot;imarith @light${filter}.list - master_bias @blight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
	echo &amp;quot;imarith dc_1s * @exptime${filter}.list @dc${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl	&lt;br /&gt;
	echo &amp;quot;imarith @blight${filter}.list - @dc${filter}.list @bdlight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
	echo &amp;quot;imarith @bdlight${filter}.list / master_flat_${filter} @bdflight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This script creates IRAF's script reduce_images.cl that should be started from IRAF's terminal. &lt;br /&gt;
AFTER the script is run from IRAF terminal, clean up the junk:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat blight*list bdlight*list bflat*list bdflat*list nbdflat*list bdark*list dc*.list &amp;gt; tmp_files.list&lt;br /&gt;
while read line; do rm $line; done &amp;lt; tmp_files.list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  BPM &amp;amp; object mask creation ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cat bpmask.cl&lt;br /&gt;
imstat dc_600s field=&amp;quot;image,mean,stddev&amp;quot; for- &amp;gt; hot.txt&lt;br /&gt;
imstat master_flat_FILTER fields=&amp;quot;image,mean&amp;quot; for- &amp;gt; cold.txt&lt;br /&gt;
cl &amp;lt; bpmask.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;gt; b) ? 1 : 0)\&amp;quot; hot&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;($2+3.*$3)*0.75}' hot.txt &amp;gt; hot.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;lt; b) ? 1 : 0)\&amp;quot; cold&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;$2*0.9}' cold.txt &amp;gt; cold.cl&lt;br /&gt;
cl &amp;lt; hot.cl&lt;br /&gt;
cl &amp;lt; cold.cl&lt;br /&gt;
# cat bpm.cl&lt;br /&gt;
imexpr &amp;quot;max(a,b)&amp;quot; bpmFILTER.pl a=hotFILTER.pl b=coldFILTER.pl&lt;br /&gt;
hedit @bdfFILTER.list BPM bpmFILTER.pl add+ ver- &lt;br /&gt;
# sed 's/FILTER/'${filter}'/g'  bpm.cl &amp;gt; dobpm.cl&lt;br /&gt;
cl &amp;lt; dobpm.cl&lt;br /&gt;
  &lt;br /&gt;
# Object masks creation&lt;br /&gt;
nproto&lt;br /&gt;
objmask @bdfFILTER.list @objbdfFILTER.list masks=&amp;quot;!BPM&amp;quot; hsig=2 lsig=2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Astrometry ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh/&lt;br /&gt;
&lt;br /&gt;
for list in $(ls bdflight*list); do&lt;br /&gt;
	while read frame; do &lt;br /&gt;
	ra=$(gethead OBJCTRA $frame | awk '{print $1&amp;quot;:&amp;quot;$2&amp;quot;:&amp;quot;$3}')&lt;br /&gt;
	dec=$(gethead OBJCTDEC $frame | awk '{print $1&amp;quot;:&amp;quot;$2&amp;quot;:&amp;quot;$3}')&lt;br /&gt;
	solve-field &amp;quot;$frame&amp;quot; --ra &amp;quot;$ra&amp;quot; --dec &amp;quot;$dec&amp;quot; --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcs&amp;quot;$frame&amp;quot; -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy --wcs bla.wcs&lt;br /&gt;
	done &amp;lt; $list&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Supersky flat ==&lt;br /&gt;
 # Creation of super sky flat, normalization to each individual image median background and final stacking&lt;br /&gt;
 # cat stat.cl&lt;br /&gt;
 real mini&lt;br /&gt;
 real sky&lt;br /&gt;
 imstat(&amp;quot;img&amp;quot;,fields=&amp;quot;min&amp;quot;,lower=INDEF,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, mini)&lt;br /&gt;
 imcalc(input=&amp;quot;img,msk&amp;quot;,output=&amp;quot;skyimage&amp;quot;,equals=&amp;quot;if(im2==0.) then im1 else &amp;quot;//mini-0.001,ver-)&lt;br /&gt;
 imstat(&amp;quot;skyimage&amp;quot;,fields=&amp;quot;midpt&amp;quot;,lower=mini-0.001,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, sky)&lt;br /&gt;
 print(&amp;quot;img&amp;quot;,&amp;quot; &amp;quot;,sky)&lt;br /&gt;
 imarith(&amp;quot;img&amp;quot;,&amp;quot;/&amp;quot;,sky,&amp;quot;norm&amp;quot;)&lt;br /&gt;
 imdelete(&amp;quot;skyimage&amp;quot;,yes)&lt;br /&gt;
 # while read line; do img=$(echo $line | awk '{print $1}'); msk=&amp;quot;obj&amp;quot;${img%.*}.pl; rsky=&amp;quot;norm&amp;quot;${img}; cat stat.cl | sed -e 's/img/'${img}'/g' \&lt;br /&gt;
 -e 's/msk/'${msk}'/g'  -e 's/norm/'${rsky}'/g'; done &amp;lt; bdf${filter}.list &amp;gt;  bla.cl&lt;br /&gt;
 cl &amp;lt; bla.cl &amp;gt; med_values.txt&lt;br /&gt;
 # ls normbdf*fit &amp;gt; norm.list&lt;br /&gt;
 imcomb @norm.list norm.fits comb=med masktype=&amp;quot;!OBJMASK&amp;quot; maskval=0&lt;br /&gt;
 # awk '{print &amp;quot;imarith norm.fits * &amp;quot;$2,&amp;quot; n&amp;quot;$1}' med_values.txt &amp;gt; donorm.cl&lt;br /&gt;
 cl &amp;lt; donorm.cl&lt;br /&gt;
 # awk '{print &amp;quot;imarith&amp;quot;,$1,&amp;quot;-&amp;quot;,&amp;quot;n&amp;quot;$1,&amp;quot;s&amp;quot;$1}' med_values.txt &amp;gt; do.cl&lt;br /&gt;
 cl &amp;lt; do.cl&lt;br /&gt;
    &lt;br /&gt;
 imcomb s@bdfFILTER.list final.fits comb=med offset=&amp;quot;wcs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Surface brightness limit ==&lt;br /&gt;
&lt;br /&gt;
 1. Calibrate the image taking non-saturated stars and not too faint stars: intercept and slope (TOPCAT with SDSS DR12 from Vizier)&lt;br /&gt;
 2. Calculate statistics inside at least 20 (empty, i.e. without objects) boxes of the size of 10&amp;quot; (for example if 1pix=0.396&amp;quot; than 10&amp;quot;~25 pix so boxes = 25 pix &amp;amp;times; 25 pix)&lt;br /&gt;
 3. Take the mean value of the standard deviation inside boxes and it's standard deviation&lt;br /&gt;
 4. Calculate SBmin and SBmax as: &lt;br /&gt;
    SBmax =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;-stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
    SBmin =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;+stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
 where &amp;lt;&amp;amp;sigma;&amp;gt; is the average standard deviation inside boxes and stdev(&amp;lt;&amp;amp;sigma;&amp;gt;) its standard deviation.&lt;br /&gt;
 5. Finally, 1 sigma surface brightness limit (SBlim) is given as:&lt;br /&gt;
    SBlim = (SBmin+SBmax)/2 +/- (SBmax-SBmin)/2&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=106</id>
		<title>CCD data reduction</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=106"/>
		<updated>2023-11-22T13:54:27Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* Astrometry */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic data reduction using IRAF ==&lt;br /&gt;
&lt;br /&gt;
Below is a bash script that creates lists of all images: biases, flats, darks and targets.&lt;br /&gt;
Special case of dark frames of 600sec that Milankovic generates is used&lt;br /&gt;
Last lines create ascii files with median values in flat frames that will be used&lt;br /&gt;
for their normalization.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;&lt;br /&gt;
The script creates reduce.cl IRAF script that should be run from iraf:&lt;br /&gt;
cl &amp;lt; reduce.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
rm *list&lt;br /&gt;
for frame in $(ls *fit); do&lt;br /&gt;
	filterType=$(gethead filter $frame)&lt;br /&gt;
	imageType=$(gethead imagetyp $frame)&lt;br /&gt;
	outFileName=$(echo $imageType | tr '[:upper:]' '[:lower:]')&lt;br /&gt;
	# test if DARK&lt;br /&gt;
	if [ ${imageType} = &amp;quot;DARK&amp;quot; ]; then&lt;br /&gt;
 		exptime=$(gethead exptime $frame | cut -d. -f1) &lt;br /&gt;
 		ls $frame &amp;gt;&amp;gt; ${outFileName}${exptime}&amp;quot;s&amp;quot;.list &lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${exptime}&amp;quot;s&amp;quot;.list&lt;br /&gt;
	else ls $frame &amp;gt;&amp;gt; ${outFileName}${filterType}.list&lt;br /&gt;
	fi&lt;br /&gt;
	# test if LIGHT and create additional lists&lt;br /&gt;
	if [ ${imageType} = &amp;quot;LIGHT&amp;quot; ]; then&lt;br /&gt;
	 	exptime=$(gethead exptime $frame | cut -d. -f1)&lt;br /&gt;
		echo $exptime &amp;gt;&amp;gt; exptime${filterType}.list&lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bdf&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bdf&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	 else if [ ${imageType} = &amp;quot;FLAT&amp;quot; ]; then&lt;br /&gt;
                echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
                echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;nbd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;nbd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	      fi&lt;br /&gt;
	 fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
# Create dark current corresponding to each light frame using exposure time&lt;br /&gt;
for exptime in $(ls exptime*.list); do &lt;br /&gt;
	filter=$(echo $exptime | sed -e s/exptime//g -e s/\.list//g);&lt;br /&gt;
	awk -v filter=${filter} '{print &amp;quot;dc&amp;quot;NR&amp;quot;_&amp;quot;filter&amp;quot;.fits&amp;quot;}' exptime${filter}.list  &amp;gt; dc${filter}.list&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce.cl ]; then rm reduce.cl; fi&lt;br /&gt;
echo &amp;quot;imdelete master_bias,dc_600s,dc_5s,dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bias.list master_bias comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark600s.list - master_bias @bdark600s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark5s.list - master_bias @bdark5s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark5s.list dc_5s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark600s.list dc_600s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl &lt;br /&gt;
echo &amp;quot;imarith dc_600s / 600 dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
&lt;br /&gt;
for flats in $(ls flat*list); do&lt;br /&gt;
        filterType=$(echo $flats | sed s/flat//g | cut -d. -f1)&lt;br /&gt;
        #echo $filterType&lt;br /&gt;
	echo &amp;quot;imarith @flat${filterType}.list - master_bias @bflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imarith @bflat${filterType}.list - dc_5s @bdflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imstat @bdflat${filterType}.list fields=\&amp;quot;image,midpt\&amp;quot; format- &amp;gt; norm${filterType}.txt&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Flat field normalization ==&lt;br /&gt;
&lt;br /&gt;
From terminal (bash):&lt;br /&gt;
&amp;lt;pre&amp;gt;  &lt;br /&gt;
for norm in $(ls norm*txt); do while read line; do echo $line | awk '! /^#/{print &amp;quot;imarith &amp;quot;$1&amp;quot; / &amp;quot;$2,&amp;quot;n&amp;quot;$1}'; done &amp;lt; $norm ; done &amp;gt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From terminal (IRAF):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cl &amp;lt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Calibration of science frames ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash/&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce_images.cl ]; then rm reduce_images.cl; fi&lt;br /&gt;
&lt;br /&gt;
for flat_list in $(ls nbdflat*list); do&lt;br /&gt;
	filter=$(echo ${flat_list} | sed -e s/nbdflat//g -e s/\.list//g);&lt;br /&gt;
	echo &amp;quot;imcomb @nbdflat${filter}.list master_flat_${filter} comb=med&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
	echo &amp;quot;imarith @light${filter}.list - master_bias @blight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
	echo &amp;quot;imarith dc_1s * @exptime${filter}.list @dc${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl	&lt;br /&gt;
	echo &amp;quot;imarith @blight${filter}.list - @dc${filter}.list @bdlight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
	echo &amp;quot;imarith @bdlight${filter}.list / master_flat_${filter} @bdflight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
cat blight*list bdlight*list bflat*list bdflat*list nbdflat*list bdark*list dc*.list &amp;gt; tmp_files.list&lt;br /&gt;
&lt;br /&gt;
while read line; do rm $line; done &amp;lt; tmp_files.list&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This script creates IRAF's script reduce_images.cl that should be started from IRAF's terminal. At the same time do some cleaning (removes intermediate files that are no longer necessary).&lt;br /&gt;
&lt;br /&gt;
==  BPM &amp;amp; object mask creation ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cat bpmask.cl&lt;br /&gt;
imstat dc_600s field=&amp;quot;image,mean,stddev&amp;quot; for- &amp;gt; hot.txt&lt;br /&gt;
imstat master_flat_FILTER fields=&amp;quot;image,mean&amp;quot; for- &amp;gt; cold.txt&lt;br /&gt;
cl &amp;lt; bpmask.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;gt; b) ? 1 : 0)\&amp;quot; hot&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;($2+3.*$3)*0.75}' hot.txt &amp;gt; hot.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;lt; b) ? 1 : 0)\&amp;quot; cold&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;$2*0.9}' cold.txt &amp;gt; cold.cl&lt;br /&gt;
cl &amp;lt; hot.cl&lt;br /&gt;
cl &amp;lt; cold.cl&lt;br /&gt;
# cat bpm.cl&lt;br /&gt;
imexpr &amp;quot;max(a,b)&amp;quot; bpmFILTER.pl a=hotFILTER.pl b=coldFILTER.pl&lt;br /&gt;
hedit @bdfFILTER.list BPM bpmFILTER.pl add+ ver- &lt;br /&gt;
# sed 's/FILTER/'${filter}'/g'  bpm.cl &amp;gt; dobpm.cl&lt;br /&gt;
cl &amp;lt; dobpm.cl&lt;br /&gt;
  &lt;br /&gt;
# Object masks creation&lt;br /&gt;
nproto&lt;br /&gt;
objmask @bdfFILTER.list @objbdfFILTER.list masks=&amp;quot;!BPM&amp;quot; hsig=2 lsig=2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Astrometry ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh/&lt;br /&gt;
&lt;br /&gt;
for list in $(ls bdflight*list); do&lt;br /&gt;
	while read frame; do &lt;br /&gt;
	ra=$(gethead OBJCTRA $frame | awk '{print $1&amp;quot;:&amp;quot;$2&amp;quot;:&amp;quot;$3}')&lt;br /&gt;
	dec=$(gethead OBJCTDEC $frame | awk '{print $1&amp;quot;:&amp;quot;$2&amp;quot;:&amp;quot;$3}')&lt;br /&gt;
	solve-field &amp;quot;$frame&amp;quot; --ra &amp;quot;$ra&amp;quot; --dec &amp;quot;$dec&amp;quot; --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcs&amp;quot;$frame&amp;quot; -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy --wcs bla.wcs&lt;br /&gt;
	done &amp;lt; $list&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Supersky flat ==&lt;br /&gt;
 # Creation of super sky flat, normalization to each individual image median background and final stacking&lt;br /&gt;
 # cat stat.cl&lt;br /&gt;
 real mini&lt;br /&gt;
 real sky&lt;br /&gt;
 imstat(&amp;quot;img&amp;quot;,fields=&amp;quot;min&amp;quot;,lower=INDEF,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, mini)&lt;br /&gt;
 imcalc(input=&amp;quot;img,msk&amp;quot;,output=&amp;quot;skyimage&amp;quot;,equals=&amp;quot;if(im2==0.) then im1 else &amp;quot;//mini-0.001,ver-)&lt;br /&gt;
 imstat(&amp;quot;skyimage&amp;quot;,fields=&amp;quot;midpt&amp;quot;,lower=mini-0.001,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, sky)&lt;br /&gt;
 print(&amp;quot;img&amp;quot;,&amp;quot; &amp;quot;,sky)&lt;br /&gt;
 imarith(&amp;quot;img&amp;quot;,&amp;quot;/&amp;quot;,sky,&amp;quot;norm&amp;quot;)&lt;br /&gt;
 imdelete(&amp;quot;skyimage&amp;quot;,yes)&lt;br /&gt;
 # while read line; do img=$(echo $line | awk '{print $1}'); msk=&amp;quot;obj&amp;quot;${img%.*}.pl; rsky=&amp;quot;norm&amp;quot;${img}; cat stat.cl | sed -e 's/img/'${img}'/g' \&lt;br /&gt;
 -e 's/msk/'${msk}'/g'  -e 's/norm/'${rsky}'/g'; done &amp;lt; bdf${filter}.list &amp;gt;  bla.cl&lt;br /&gt;
 cl &amp;lt; bla.cl &amp;gt; med_values.txt&lt;br /&gt;
 # ls normbdf*fit &amp;gt; norm.list&lt;br /&gt;
 imcomb @norm.list norm.fits comb=med masktype=&amp;quot;!OBJMASK&amp;quot; maskval=0&lt;br /&gt;
 # awk '{print &amp;quot;imarith norm.fits * &amp;quot;$2,&amp;quot; n&amp;quot;$1}' med_values.txt &amp;gt; donorm.cl&lt;br /&gt;
 cl &amp;lt; donorm.cl&lt;br /&gt;
 # awk '{print &amp;quot;imarith&amp;quot;,$1,&amp;quot;-&amp;quot;,&amp;quot;n&amp;quot;$1,&amp;quot;s&amp;quot;$1}' med_values.txt &amp;gt; do.cl&lt;br /&gt;
 cl &amp;lt; do.cl&lt;br /&gt;
    &lt;br /&gt;
 imcomb s@bdfFILTER.list final.fits comb=med offset=&amp;quot;wcs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Surface brightness limit ==&lt;br /&gt;
&lt;br /&gt;
 1. Calibrate the image taking non-saturated stars and not too faint stars: intercept and slope (TOPCAT with SDSS DR12 from Vizier)&lt;br /&gt;
 2. Calculate statistics inside at least 20 (empty, i.e. without objects) boxes of the size of 10&amp;quot; (for example if 1pix=0.396&amp;quot; than 10&amp;quot;~25 pix so boxes = 25 pix &amp;amp;times; 25 pix)&lt;br /&gt;
 3. Take the mean value of the standard deviation inside boxes and it's standard deviation&lt;br /&gt;
 4. Calculate SBmin and SBmax as: &lt;br /&gt;
    SBmax =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;-stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
    SBmin =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;+stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
 where &amp;lt;&amp;amp;sigma;&amp;gt; is the average standard deviation inside boxes and stdev(&amp;lt;&amp;amp;sigma;&amp;gt;) its standard deviation.&lt;br /&gt;
 5. Finally, 1 sigma surface brightness limit (SBlim) is given as:&lt;br /&gt;
    SBlim = (SBmin+SBmax)/2 +/- (SBmax-SBmin)/2&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=105</id>
		<title>CCD data reduction</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=105"/>
		<updated>2023-11-22T13:54:04Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* Astrometry */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic data reduction using IRAF ==&lt;br /&gt;
&lt;br /&gt;
Below is a bash script that creates lists of all images: biases, flats, darks and targets.&lt;br /&gt;
Special case of dark frames of 600sec that Milankovic generates is used&lt;br /&gt;
Last lines create ascii files with median values in flat frames that will be used&lt;br /&gt;
for their normalization.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;&lt;br /&gt;
The script creates reduce.cl IRAF script that should be run from iraf:&lt;br /&gt;
cl &amp;lt; reduce.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
rm *list&lt;br /&gt;
for frame in $(ls *fit); do&lt;br /&gt;
	filterType=$(gethead filter $frame)&lt;br /&gt;
	imageType=$(gethead imagetyp $frame)&lt;br /&gt;
	outFileName=$(echo $imageType | tr '[:upper:]' '[:lower:]')&lt;br /&gt;
	# test if DARK&lt;br /&gt;
	if [ ${imageType} = &amp;quot;DARK&amp;quot; ]; then&lt;br /&gt;
 		exptime=$(gethead exptime $frame | cut -d. -f1) &lt;br /&gt;
 		ls $frame &amp;gt;&amp;gt; ${outFileName}${exptime}&amp;quot;s&amp;quot;.list &lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${exptime}&amp;quot;s&amp;quot;.list&lt;br /&gt;
	else ls $frame &amp;gt;&amp;gt; ${outFileName}${filterType}.list&lt;br /&gt;
	fi&lt;br /&gt;
	# test if LIGHT and create additional lists&lt;br /&gt;
	if [ ${imageType} = &amp;quot;LIGHT&amp;quot; ]; then&lt;br /&gt;
	 	exptime=$(gethead exptime $frame | cut -d. -f1)&lt;br /&gt;
		echo $exptime &amp;gt;&amp;gt; exptime${filterType}.list&lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bdf&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bdf&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	 else if [ ${imageType} = &amp;quot;FLAT&amp;quot; ]; then&lt;br /&gt;
                echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
                echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;nbd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;nbd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	      fi&lt;br /&gt;
	 fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
# Create dark current corresponding to each light frame using exposure time&lt;br /&gt;
for exptime in $(ls exptime*.list); do &lt;br /&gt;
	filter=$(echo $exptime | sed -e s/exptime//g -e s/\.list//g);&lt;br /&gt;
	awk -v filter=${filter} '{print &amp;quot;dc&amp;quot;NR&amp;quot;_&amp;quot;filter&amp;quot;.fits&amp;quot;}' exptime${filter}.list  &amp;gt; dc${filter}.list&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce.cl ]; then rm reduce.cl; fi&lt;br /&gt;
echo &amp;quot;imdelete master_bias,dc_600s,dc_5s,dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bias.list master_bias comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark600s.list - master_bias @bdark600s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark5s.list - master_bias @bdark5s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark5s.list dc_5s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark600s.list dc_600s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl &lt;br /&gt;
echo &amp;quot;imarith dc_600s / 600 dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
&lt;br /&gt;
for flats in $(ls flat*list); do&lt;br /&gt;
        filterType=$(echo $flats | sed s/flat//g | cut -d. -f1)&lt;br /&gt;
        #echo $filterType&lt;br /&gt;
	echo &amp;quot;imarith @flat${filterType}.list - master_bias @bflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imarith @bflat${filterType}.list - dc_5s @bdflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imstat @bdflat${filterType}.list fields=\&amp;quot;image,midpt\&amp;quot; format- &amp;gt; norm${filterType}.txt&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Flat field normalization ==&lt;br /&gt;
&lt;br /&gt;
From terminal (bash):&lt;br /&gt;
&amp;lt;pre&amp;gt;  &lt;br /&gt;
for norm in $(ls norm*txt); do while read line; do echo $line | awk '! /^#/{print &amp;quot;imarith &amp;quot;$1&amp;quot; / &amp;quot;$2,&amp;quot;n&amp;quot;$1}'; done &amp;lt; $norm ; done &amp;gt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From terminal (IRAF):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cl &amp;lt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Calibration of science frames ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash/&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce_images.cl ]; then rm reduce_images.cl; fi&lt;br /&gt;
&lt;br /&gt;
for flat_list in $(ls nbdflat*list); do&lt;br /&gt;
	filter=$(echo ${flat_list} | sed -e s/nbdflat//g -e s/\.list//g);&lt;br /&gt;
	echo &amp;quot;imcomb @nbdflat${filter}.list master_flat_${filter} comb=med&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
	echo &amp;quot;imarith @light${filter}.list - master_bias @blight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
	echo &amp;quot;imarith dc_1s * @exptime${filter}.list @dc${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl	&lt;br /&gt;
	echo &amp;quot;imarith @blight${filter}.list - @dc${filter}.list @bdlight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
	echo &amp;quot;imarith @bdlight${filter}.list / master_flat_${filter} @bdflight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
cat blight*list bdlight*list bflat*list bdflat*list nbdflat*list bdark*list dc*.list &amp;gt; tmp_files.list&lt;br /&gt;
&lt;br /&gt;
while read line; do rm $line; done &amp;lt; tmp_files.list&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This script creates IRAF's script reduce_images.cl that should be started from IRAF's terminal. At the same time do some cleaning (removes intermediate files that are no longer necessary).&lt;br /&gt;
&lt;br /&gt;
==  BPM &amp;amp; object mask creation ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cat bpmask.cl&lt;br /&gt;
imstat dc_600s field=&amp;quot;image,mean,stddev&amp;quot; for- &amp;gt; hot.txt&lt;br /&gt;
imstat master_flat_FILTER fields=&amp;quot;image,mean&amp;quot; for- &amp;gt; cold.txt&lt;br /&gt;
cl &amp;lt; bpmask.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;gt; b) ? 1 : 0)\&amp;quot; hot&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;($2+3.*$3)*0.75}' hot.txt &amp;gt; hot.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;lt; b) ? 1 : 0)\&amp;quot; cold&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;$2*0.9}' cold.txt &amp;gt; cold.cl&lt;br /&gt;
cl &amp;lt; hot.cl&lt;br /&gt;
cl &amp;lt; cold.cl&lt;br /&gt;
# cat bpm.cl&lt;br /&gt;
imexpr &amp;quot;max(a,b)&amp;quot; bpmFILTER.pl a=hotFILTER.pl b=coldFILTER.pl&lt;br /&gt;
hedit @bdfFILTER.list BPM bpmFILTER.pl add+ ver- &lt;br /&gt;
# sed 's/FILTER/'${filter}'/g'  bpm.cl &amp;gt; dobpm.cl&lt;br /&gt;
cl &amp;lt; dobpm.cl&lt;br /&gt;
  &lt;br /&gt;
# Object masks creation&lt;br /&gt;
nproto&lt;br /&gt;
objmask @bdfFILTER.list @objbdfFILTER.list masks=&amp;quot;!BPM&amp;quot; hsig=2 lsig=2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Astrometry ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh/&lt;br /&gt;
&lt;br /&gt;
for list in $(ls bdflight*list); do&lt;br /&gt;
	while read frame; do &lt;br /&gt;
	filter=$(echo $frame | sed -e s/bdflight//g -e s/\.list//g);&lt;br /&gt;
	ra=$(gethead OBJCTRA $frame | awk '{print $1&amp;quot;:&amp;quot;$2&amp;quot;:&amp;quot;$3}')&lt;br /&gt;
	dec=$(gethead OBJCTDEC $frame | awk '{print $1&amp;quot;:&amp;quot;$2&amp;quot;:&amp;quot;$3}')&lt;br /&gt;
	solve-field &amp;quot;$frame&amp;quot; --ra &amp;quot;$ra&amp;quot; --dec &amp;quot;$dec&amp;quot; --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcs&amp;quot;$frame&amp;quot; -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy --wcs bla.wcs&lt;br /&gt;
	done &amp;lt; $list&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Supersky flat ==&lt;br /&gt;
 # Creation of super sky flat, normalization to each individual image median background and final stacking&lt;br /&gt;
 # cat stat.cl&lt;br /&gt;
 real mini&lt;br /&gt;
 real sky&lt;br /&gt;
 imstat(&amp;quot;img&amp;quot;,fields=&amp;quot;min&amp;quot;,lower=INDEF,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, mini)&lt;br /&gt;
 imcalc(input=&amp;quot;img,msk&amp;quot;,output=&amp;quot;skyimage&amp;quot;,equals=&amp;quot;if(im2==0.) then im1 else &amp;quot;//mini-0.001,ver-)&lt;br /&gt;
 imstat(&amp;quot;skyimage&amp;quot;,fields=&amp;quot;midpt&amp;quot;,lower=mini-0.001,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, sky)&lt;br /&gt;
 print(&amp;quot;img&amp;quot;,&amp;quot; &amp;quot;,sky)&lt;br /&gt;
 imarith(&amp;quot;img&amp;quot;,&amp;quot;/&amp;quot;,sky,&amp;quot;norm&amp;quot;)&lt;br /&gt;
 imdelete(&amp;quot;skyimage&amp;quot;,yes)&lt;br /&gt;
 # while read line; do img=$(echo $line | awk '{print $1}'); msk=&amp;quot;obj&amp;quot;${img%.*}.pl; rsky=&amp;quot;norm&amp;quot;${img}; cat stat.cl | sed -e 's/img/'${img}'/g' \&lt;br /&gt;
 -e 's/msk/'${msk}'/g'  -e 's/norm/'${rsky}'/g'; done &amp;lt; bdf${filter}.list &amp;gt;  bla.cl&lt;br /&gt;
 cl &amp;lt; bla.cl &amp;gt; med_values.txt&lt;br /&gt;
 # ls normbdf*fit &amp;gt; norm.list&lt;br /&gt;
 imcomb @norm.list norm.fits comb=med masktype=&amp;quot;!OBJMASK&amp;quot; maskval=0&lt;br /&gt;
 # awk '{print &amp;quot;imarith norm.fits * &amp;quot;$2,&amp;quot; n&amp;quot;$1}' med_values.txt &amp;gt; donorm.cl&lt;br /&gt;
 cl &amp;lt; donorm.cl&lt;br /&gt;
 # awk '{print &amp;quot;imarith&amp;quot;,$1,&amp;quot;-&amp;quot;,&amp;quot;n&amp;quot;$1,&amp;quot;s&amp;quot;$1}' med_values.txt &amp;gt; do.cl&lt;br /&gt;
 cl &amp;lt; do.cl&lt;br /&gt;
    &lt;br /&gt;
 imcomb s@bdfFILTER.list final.fits comb=med offset=&amp;quot;wcs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Surface brightness limit ==&lt;br /&gt;
&lt;br /&gt;
 1. Calibrate the image taking non-saturated stars and not too faint stars: intercept and slope (TOPCAT with SDSS DR12 from Vizier)&lt;br /&gt;
 2. Calculate statistics inside at least 20 (empty, i.e. without objects) boxes of the size of 10&amp;quot; (for example if 1pix=0.396&amp;quot; than 10&amp;quot;~25 pix so boxes = 25 pix &amp;amp;times; 25 pix)&lt;br /&gt;
 3. Take the mean value of the standard deviation inside boxes and it's standard deviation&lt;br /&gt;
 4. Calculate SBmin and SBmax as: &lt;br /&gt;
    SBmax =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;-stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
    SBmin =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;+stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
 where &amp;lt;&amp;amp;sigma;&amp;gt; is the average standard deviation inside boxes and stdev(&amp;lt;&amp;amp;sigma;&amp;gt;) its standard deviation.&lt;br /&gt;
 5. Finally, 1 sigma surface brightness limit (SBlim) is given as:&lt;br /&gt;
    SBlim = (SBmin+SBmax)/2 +/- (SBmax-SBmin)/2&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=104</id>
		<title>CCD data reduction</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=104"/>
		<updated>2023-11-22T13:45:24Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* Astrometry */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic data reduction using IRAF ==&lt;br /&gt;
&lt;br /&gt;
Below is a bash script that creates lists of all images: biases, flats, darks and targets.&lt;br /&gt;
Special case of dark frames of 600sec that Milankovic generates is used&lt;br /&gt;
Last lines create ascii files with median values in flat frames that will be used&lt;br /&gt;
for their normalization.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;&lt;br /&gt;
The script creates reduce.cl IRAF script that should be run from iraf:&lt;br /&gt;
cl &amp;lt; reduce.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
rm *list&lt;br /&gt;
for frame in $(ls *fit); do&lt;br /&gt;
	filterType=$(gethead filter $frame)&lt;br /&gt;
	imageType=$(gethead imagetyp $frame)&lt;br /&gt;
	outFileName=$(echo $imageType | tr '[:upper:]' '[:lower:]')&lt;br /&gt;
	# test if DARK&lt;br /&gt;
	if [ ${imageType} = &amp;quot;DARK&amp;quot; ]; then&lt;br /&gt;
 		exptime=$(gethead exptime $frame | cut -d. -f1) &lt;br /&gt;
 		ls $frame &amp;gt;&amp;gt; ${outFileName}${exptime}&amp;quot;s&amp;quot;.list &lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${exptime}&amp;quot;s&amp;quot;.list&lt;br /&gt;
	else ls $frame &amp;gt;&amp;gt; ${outFileName}${filterType}.list&lt;br /&gt;
	fi&lt;br /&gt;
	# test if LIGHT and create additional lists&lt;br /&gt;
	if [ ${imageType} = &amp;quot;LIGHT&amp;quot; ]; then&lt;br /&gt;
	 	exptime=$(gethead exptime $frame | cut -d. -f1)&lt;br /&gt;
		echo $exptime &amp;gt;&amp;gt; exptime${filterType}.list&lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bdf&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bdf&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	 else if [ ${imageType} = &amp;quot;FLAT&amp;quot; ]; then&lt;br /&gt;
                echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
                echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;nbd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;nbd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	      fi&lt;br /&gt;
	 fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
# Create dark current corresponding to each light frame using exposure time&lt;br /&gt;
for exptime in $(ls exptime*.list); do &lt;br /&gt;
	filter=$(echo $exptime | sed -e s/exptime//g -e s/\.list//g);&lt;br /&gt;
	awk -v filter=${filter} '{print &amp;quot;dc&amp;quot;NR&amp;quot;_&amp;quot;filter&amp;quot;.fits&amp;quot;}' exptime${filter}.list  &amp;gt; dc${filter}.list&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce.cl ]; then rm reduce.cl; fi&lt;br /&gt;
echo &amp;quot;imdelete master_bias,dc_600s,dc_5s,dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bias.list master_bias comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark600s.list - master_bias @bdark600s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark5s.list - master_bias @bdark5s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark5s.list dc_5s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark600s.list dc_600s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl &lt;br /&gt;
echo &amp;quot;imarith dc_600s / 600 dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
&lt;br /&gt;
for flats in $(ls flat*list); do&lt;br /&gt;
        filterType=$(echo $flats | sed s/flat//g | cut -d. -f1)&lt;br /&gt;
        #echo $filterType&lt;br /&gt;
	echo &amp;quot;imarith @flat${filterType}.list - master_bias @bflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imarith @bflat${filterType}.list - dc_5s @bdflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imstat @bdflat${filterType}.list fields=\&amp;quot;image,midpt\&amp;quot; format- &amp;gt; norm${filterType}.txt&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Flat field normalization ==&lt;br /&gt;
&lt;br /&gt;
From terminal (bash):&lt;br /&gt;
&amp;lt;pre&amp;gt;  &lt;br /&gt;
for norm in $(ls norm*txt); do while read line; do echo $line | awk '! /^#/{print &amp;quot;imarith &amp;quot;$1&amp;quot; / &amp;quot;$2,&amp;quot;n&amp;quot;$1}'; done &amp;lt; $norm ; done &amp;gt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From terminal (IRAF):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cl &amp;lt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Calibration of science frames ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash/&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce_images.cl ]; then rm reduce_images.cl; fi&lt;br /&gt;
&lt;br /&gt;
for flat_list in $(ls nbdflat*list); do&lt;br /&gt;
	filter=$(echo ${flat_list} | sed -e s/nbdflat//g -e s/\.list//g);&lt;br /&gt;
	echo &amp;quot;imcomb @nbdflat${filter}.list master_flat_${filter} comb=med&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
	echo &amp;quot;imarith @light${filter}.list - master_bias @blight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
	echo &amp;quot;imarith dc_1s * @exptime${filter}.list @dc${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl	&lt;br /&gt;
	echo &amp;quot;imarith @blight${filter}.list - @dc${filter}.list @bdlight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
	echo &amp;quot;imarith @bdlight${filter}.list / master_flat_${filter} @bdflight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
cat blight*list bdlight*list bflat*list bdflat*list nbdflat*list bdark*list dc*.list &amp;gt; tmp_files.list&lt;br /&gt;
&lt;br /&gt;
while read line; do rm $line; done &amp;lt; tmp_files.list&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This script creates IRAF's script reduce_images.cl that should be started from IRAF's terminal. At the same time do some cleaning (removes intermediate files that are no longer necessary).&lt;br /&gt;
&lt;br /&gt;
==  BPM &amp;amp; object mask creation ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cat bpmask.cl&lt;br /&gt;
imstat dc_600s field=&amp;quot;image,mean,stddev&amp;quot; for- &amp;gt; hot.txt&lt;br /&gt;
imstat master_flat_FILTER fields=&amp;quot;image,mean&amp;quot; for- &amp;gt; cold.txt&lt;br /&gt;
cl &amp;lt; bpmask.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;gt; b) ? 1 : 0)\&amp;quot; hot&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;($2+3.*$3)*0.75}' hot.txt &amp;gt; hot.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;lt; b) ? 1 : 0)\&amp;quot; cold&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;$2*0.9}' cold.txt &amp;gt; cold.cl&lt;br /&gt;
cl &amp;lt; hot.cl&lt;br /&gt;
cl &amp;lt; cold.cl&lt;br /&gt;
# cat bpm.cl&lt;br /&gt;
imexpr &amp;quot;max(a,b)&amp;quot; bpmFILTER.pl a=hotFILTER.pl b=coldFILTER.pl&lt;br /&gt;
hedit @bdfFILTER.list BPM bpmFILTER.pl add+ ver- &lt;br /&gt;
# sed 's/FILTER/'${filter}'/g'  bpm.cl &amp;gt; dobpm.cl&lt;br /&gt;
cl &amp;lt; dobpm.cl&lt;br /&gt;
  &lt;br /&gt;
# Object masks creation&lt;br /&gt;
nproto&lt;br /&gt;
objmask @bdfFILTER.list @objbdfFILTER.list masks=&amp;quot;!BPM&amp;quot; hsig=2 lsig=2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Astrometry ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh/&lt;br /&gt;
&lt;br /&gt;
for list in $(ls bdflight*list); do&lt;br /&gt;
	while read frame; do &lt;br /&gt;
	filter=$(echo $frame | sed -e s/bdflight//g -e s/\.list//g);&lt;br /&gt;
	ra=$(gethead OBJCTRA $frame | awk '{print $1&amp;quot;:&amp;quot;$2&amp;quot;:&amp;quot;$3}')&lt;br /&gt;
	dec=$(gethead OBJCTDEC $frame | awk '{print $1&amp;quot;:&amp;quot;$2&amp;quot;:&amp;quot;$3}')&lt;br /&gt;
	echo &amp;quot;solve-field &amp;quot;$frame&amp;quot; --ra &amp;quot;$ra&amp;quot; --dec &amp;quot;$dec&amp;quot; --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcs&amp;quot;$frame&amp;quot; -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy --wcs bla.wcs&amp;quot;&lt;br /&gt;
	done &amp;lt; $list&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Supersky flat ==&lt;br /&gt;
 # Creation of super sky flat, normalization to each individual image median background and final stacking&lt;br /&gt;
 # cat stat.cl&lt;br /&gt;
 real mini&lt;br /&gt;
 real sky&lt;br /&gt;
 imstat(&amp;quot;img&amp;quot;,fields=&amp;quot;min&amp;quot;,lower=INDEF,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, mini)&lt;br /&gt;
 imcalc(input=&amp;quot;img,msk&amp;quot;,output=&amp;quot;skyimage&amp;quot;,equals=&amp;quot;if(im2==0.) then im1 else &amp;quot;//mini-0.001,ver-)&lt;br /&gt;
 imstat(&amp;quot;skyimage&amp;quot;,fields=&amp;quot;midpt&amp;quot;,lower=mini-0.001,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, sky)&lt;br /&gt;
 print(&amp;quot;img&amp;quot;,&amp;quot; &amp;quot;,sky)&lt;br /&gt;
 imarith(&amp;quot;img&amp;quot;,&amp;quot;/&amp;quot;,sky,&amp;quot;norm&amp;quot;)&lt;br /&gt;
 imdelete(&amp;quot;skyimage&amp;quot;,yes)&lt;br /&gt;
 # while read line; do img=$(echo $line | awk '{print $1}'); msk=&amp;quot;obj&amp;quot;${img%.*}.pl; rsky=&amp;quot;norm&amp;quot;${img}; cat stat.cl | sed -e 's/img/'${img}'/g' \&lt;br /&gt;
 -e 's/msk/'${msk}'/g'  -e 's/norm/'${rsky}'/g'; done &amp;lt; bdf${filter}.list &amp;gt;  bla.cl&lt;br /&gt;
 cl &amp;lt; bla.cl &amp;gt; med_values.txt&lt;br /&gt;
 # ls normbdf*fit &amp;gt; norm.list&lt;br /&gt;
 imcomb @norm.list norm.fits comb=med masktype=&amp;quot;!OBJMASK&amp;quot; maskval=0&lt;br /&gt;
 # awk '{print &amp;quot;imarith norm.fits * &amp;quot;$2,&amp;quot; n&amp;quot;$1}' med_values.txt &amp;gt; donorm.cl&lt;br /&gt;
 cl &amp;lt; donorm.cl&lt;br /&gt;
 # awk '{print &amp;quot;imarith&amp;quot;,$1,&amp;quot;-&amp;quot;,&amp;quot;n&amp;quot;$1,&amp;quot;s&amp;quot;$1}' med_values.txt &amp;gt; do.cl&lt;br /&gt;
 cl &amp;lt; do.cl&lt;br /&gt;
    &lt;br /&gt;
 imcomb s@bdfFILTER.list final.fits comb=med offset=&amp;quot;wcs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Surface brightness limit ==&lt;br /&gt;
&lt;br /&gt;
 1. Calibrate the image taking non-saturated stars and not too faint stars: intercept and slope (TOPCAT with SDSS DR12 from Vizier)&lt;br /&gt;
 2. Calculate statistics inside at least 20 (empty, i.e. without objects) boxes of the size of 10&amp;quot; (for example if 1pix=0.396&amp;quot; than 10&amp;quot;~25 pix so boxes = 25 pix &amp;amp;times; 25 pix)&lt;br /&gt;
 3. Take the mean value of the standard deviation inside boxes and it's standard deviation&lt;br /&gt;
 4. Calculate SBmin and SBmax as: &lt;br /&gt;
    SBmax =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;-stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
    SBmin =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;+stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
 where &amp;lt;&amp;amp;sigma;&amp;gt; is the average standard deviation inside boxes and stdev(&amp;lt;&amp;amp;sigma;&amp;gt;) its standard deviation.&lt;br /&gt;
 5. Finally, 1 sigma surface brightness limit (SBlim) is given as:&lt;br /&gt;
    SBlim = (SBmin+SBmax)/2 +/- (SBmax-SBmin)/2&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=103</id>
		<title>CCD data reduction</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=103"/>
		<updated>2023-11-22T13:44:20Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* Flat field normalization */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic data reduction using IRAF ==&lt;br /&gt;
&lt;br /&gt;
Below is a bash script that creates lists of all images: biases, flats, darks and targets.&lt;br /&gt;
Special case of dark frames of 600sec that Milankovic generates is used&lt;br /&gt;
Last lines create ascii files with median values in flat frames that will be used&lt;br /&gt;
for their normalization.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;&lt;br /&gt;
The script creates reduce.cl IRAF script that should be run from iraf:&lt;br /&gt;
cl &amp;lt; reduce.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
rm *list&lt;br /&gt;
for frame in $(ls *fit); do&lt;br /&gt;
	filterType=$(gethead filter $frame)&lt;br /&gt;
	imageType=$(gethead imagetyp $frame)&lt;br /&gt;
	outFileName=$(echo $imageType | tr '[:upper:]' '[:lower:]')&lt;br /&gt;
	# test if DARK&lt;br /&gt;
	if [ ${imageType} = &amp;quot;DARK&amp;quot; ]; then&lt;br /&gt;
 		exptime=$(gethead exptime $frame | cut -d. -f1) &lt;br /&gt;
 		ls $frame &amp;gt;&amp;gt; ${outFileName}${exptime}&amp;quot;s&amp;quot;.list &lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${exptime}&amp;quot;s&amp;quot;.list&lt;br /&gt;
	else ls $frame &amp;gt;&amp;gt; ${outFileName}${filterType}.list&lt;br /&gt;
	fi&lt;br /&gt;
	# test if LIGHT and create additional lists&lt;br /&gt;
	if [ ${imageType} = &amp;quot;LIGHT&amp;quot; ]; then&lt;br /&gt;
	 	exptime=$(gethead exptime $frame | cut -d. -f1)&lt;br /&gt;
		echo $exptime &amp;gt;&amp;gt; exptime${filterType}.list&lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bdf&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bdf&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	 else if [ ${imageType} = &amp;quot;FLAT&amp;quot; ]; then&lt;br /&gt;
                echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
                echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;nbd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;nbd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	      fi&lt;br /&gt;
	 fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
# Create dark current corresponding to each light frame using exposure time&lt;br /&gt;
for exptime in $(ls exptime*.list); do &lt;br /&gt;
	filter=$(echo $exptime | sed -e s/exptime//g -e s/\.list//g);&lt;br /&gt;
	awk -v filter=${filter} '{print &amp;quot;dc&amp;quot;NR&amp;quot;_&amp;quot;filter&amp;quot;.fits&amp;quot;}' exptime${filter}.list  &amp;gt; dc${filter}.list&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce.cl ]; then rm reduce.cl; fi&lt;br /&gt;
echo &amp;quot;imdelete master_bias,dc_600s,dc_5s,dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bias.list master_bias comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark600s.list - master_bias @bdark600s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark5s.list - master_bias @bdark5s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark5s.list dc_5s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark600s.list dc_600s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl &lt;br /&gt;
echo &amp;quot;imarith dc_600s / 600 dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
&lt;br /&gt;
for flats in $(ls flat*list); do&lt;br /&gt;
        filterType=$(echo $flats | sed s/flat//g | cut -d. -f1)&lt;br /&gt;
        #echo $filterType&lt;br /&gt;
	echo &amp;quot;imarith @flat${filterType}.list - master_bias @bflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imarith @bflat${filterType}.list - dc_5s @bdflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imstat @bdflat${filterType}.list fields=\&amp;quot;image,midpt\&amp;quot; format- &amp;gt; norm${filterType}.txt&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Flat field normalization ==&lt;br /&gt;
&lt;br /&gt;
From terminal (bash):&lt;br /&gt;
&amp;lt;pre&amp;gt;  &lt;br /&gt;
for norm in $(ls norm*txt); do while read line; do echo $line | awk '! /^#/{print &amp;quot;imarith &amp;quot;$1&amp;quot; / &amp;quot;$2,&amp;quot;n&amp;quot;$1}'; done &amp;lt; $norm ; done &amp;gt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From terminal (IRAF):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cl &amp;lt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Calibration of science frames ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash/&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce_images.cl ]; then rm reduce_images.cl; fi&lt;br /&gt;
&lt;br /&gt;
for flat_list in $(ls nbdflat*list); do&lt;br /&gt;
	filter=$(echo ${flat_list} | sed -e s/nbdflat//g -e s/\.list//g);&lt;br /&gt;
	echo &amp;quot;imcomb @nbdflat${filter}.list master_flat_${filter} comb=med&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
	echo &amp;quot;imarith @light${filter}.list - master_bias @blight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
	echo &amp;quot;imarith dc_1s * @exptime${filter}.list @dc${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl	&lt;br /&gt;
	echo &amp;quot;imarith @blight${filter}.list - @dc${filter}.list @bdlight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
	echo &amp;quot;imarith @bdlight${filter}.list / master_flat_${filter} @bdflight${filter}.list&amp;quot; &amp;gt;&amp;gt; reduce_images.cl&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
cat blight*list bdlight*list bflat*list bdflat*list nbdflat*list bdark*list dc*.list &amp;gt; tmp_files.list&lt;br /&gt;
&lt;br /&gt;
while read line; do rm $line; done &amp;lt; tmp_files.list&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This script creates IRAF's script reduce_images.cl that should be started from IRAF's terminal. At the same time do some cleaning (removes intermediate files that are no longer necessary).&lt;br /&gt;
&lt;br /&gt;
==  BPM &amp;amp; object mask creation ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cat bpmask.cl&lt;br /&gt;
imstat dc_600s field=&amp;quot;image,mean,stddev&amp;quot; for- &amp;gt; hot.txt&lt;br /&gt;
imstat master_flat_FILTER fields=&amp;quot;image,mean&amp;quot; for- &amp;gt; cold.txt&lt;br /&gt;
cl &amp;lt; bpmask.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;gt; b) ? 1 : 0)\&amp;quot; hot&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;($2+3.*$3)*0.75}' hot.txt &amp;gt; hot.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;lt; b) ? 1 : 0)\&amp;quot; cold&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;$2*0.9}' cold.txt &amp;gt; cold.cl&lt;br /&gt;
cl &amp;lt; hot.cl&lt;br /&gt;
cl &amp;lt; cold.cl&lt;br /&gt;
# cat bpm.cl&lt;br /&gt;
imexpr &amp;quot;max(a,b)&amp;quot; bpmFILTER.pl a=hotFILTER.pl b=coldFILTER.pl&lt;br /&gt;
hedit @bdfFILTER.list BPM bpmFILTER.pl add+ ver- &lt;br /&gt;
# sed 's/FILTER/'${filter}'/g'  bpm.cl &amp;gt; dobpm.cl&lt;br /&gt;
cl &amp;lt; dobpm.cl&lt;br /&gt;
  &lt;br /&gt;
# Object masks creation&lt;br /&gt;
nproto&lt;br /&gt;
objmask @bdfFILTER.list @objbdfFILTER.list masks=&amp;quot;!BPM&amp;quot; hsig=2 lsig=2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Astrometry ==&lt;br /&gt;
 # cat astrometry.sh&lt;br /&gt;
 gethead OBJCTRA @bdfFILTER.list &amp;gt; name_ra.txt &lt;br /&gt;
 gethead OBJCTDEC @bdfFILTER.list | awk '{print $2,$3,$4}' &amp;gt; dec.txt&lt;br /&gt;
 paste -d&amp;quot; &amp;quot; name_ra.txt dec.txt | awk '{print $1,($2+$3/60+$4/3600)*15,$5+$6/60+$7/3600}' &amp;gt; astrometryFILTER.txt&lt;br /&gt;
 # sed s/FILTER/${filter}/g astrometry.sh  &amp;gt; astrometry${filter}.sh&lt;br /&gt;
 &lt;br /&gt;
 sh astrometry${filter}.sh&lt;br /&gt;
&lt;br /&gt;
  # This could be used:&lt;br /&gt;
  # cat komanda.sh&lt;br /&gt;
  solve-field img --ra imagera --dec imagedec --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center --wcs img.wcs &lt;br /&gt;
  ### The next command creates new files instead of just wcs binaries that can later be added to the header. It's a stand-alone command. And should be ignored.&lt;br /&gt;
  ### solve-field img --ra imagera --dec imagedec --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcsimg.fit  \ &lt;br /&gt;
  ###  -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy &lt;br /&gt;
  #while read line; do img=$(echo $line | awk '{print $1}'); imagera=$(echo $line | awk '{print $2}'); imagedec=$(echo $line | awk '{print $3}'); sed -e 's/img/'$img'/g' \ &lt;br /&gt;
 -e 's/imagera/'${imagera}'/g' -e 's/imagedec/'${imagedec}'/g' komanda.sh; done &amp;lt; astrometry${filter}.txt &amp;gt; doAstrometry.sh &lt;br /&gt;
 # Or this:&lt;br /&gt;
  awk '{print &amp;quot;solve-field &amp;quot;$1&amp;quot; --ra &amp;quot;$2&amp;quot; --dec &amp;quot;$3&amp;quot; --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcs&amp;quot;$1&amp;quot; \ &lt;br /&gt;
  -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy --wcs bla.wcs&amp;quot;}' astrometry${filter}.txt &amp;gt; doAstrometry.sh&lt;br /&gt;
&lt;br /&gt;
 # /bin/bash doAstrometry.sh&lt;br /&gt;
  #ls *wcs &amp;gt; wcs${filter}.list&lt;br /&gt;
  # echo &amp;quot;wcscopy @bdf${filter}.list @wcs${filter}.list ver-&amp;quot; &amp;gt; dowcs.cl&lt;br /&gt;
 cl &amp;lt; dowcs.cl&lt;br /&gt;
&lt;br /&gt;
== Supersky flat ==&lt;br /&gt;
 # Creation of super sky flat, normalization to each individual image median background and final stacking&lt;br /&gt;
 # cat stat.cl&lt;br /&gt;
 real mini&lt;br /&gt;
 real sky&lt;br /&gt;
 imstat(&amp;quot;img&amp;quot;,fields=&amp;quot;min&amp;quot;,lower=INDEF,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, mini)&lt;br /&gt;
 imcalc(input=&amp;quot;img,msk&amp;quot;,output=&amp;quot;skyimage&amp;quot;,equals=&amp;quot;if(im2==0.) then im1 else &amp;quot;//mini-0.001,ver-)&lt;br /&gt;
 imstat(&amp;quot;skyimage&amp;quot;,fields=&amp;quot;midpt&amp;quot;,lower=mini-0.001,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, sky)&lt;br /&gt;
 print(&amp;quot;img&amp;quot;,&amp;quot; &amp;quot;,sky)&lt;br /&gt;
 imarith(&amp;quot;img&amp;quot;,&amp;quot;/&amp;quot;,sky,&amp;quot;norm&amp;quot;)&lt;br /&gt;
 imdelete(&amp;quot;skyimage&amp;quot;,yes)&lt;br /&gt;
 # while read line; do img=$(echo $line | awk '{print $1}'); msk=&amp;quot;obj&amp;quot;${img%.*}.pl; rsky=&amp;quot;norm&amp;quot;${img}; cat stat.cl | sed -e 's/img/'${img}'/g' \&lt;br /&gt;
 -e 's/msk/'${msk}'/g'  -e 's/norm/'${rsky}'/g'; done &amp;lt; bdf${filter}.list &amp;gt;  bla.cl&lt;br /&gt;
 cl &amp;lt; bla.cl &amp;gt; med_values.txt&lt;br /&gt;
 # ls normbdf*fit &amp;gt; norm.list&lt;br /&gt;
 imcomb @norm.list norm.fits comb=med masktype=&amp;quot;!OBJMASK&amp;quot; maskval=0&lt;br /&gt;
 # awk '{print &amp;quot;imarith norm.fits * &amp;quot;$2,&amp;quot; n&amp;quot;$1}' med_values.txt &amp;gt; donorm.cl&lt;br /&gt;
 cl &amp;lt; donorm.cl&lt;br /&gt;
 # awk '{print &amp;quot;imarith&amp;quot;,$1,&amp;quot;-&amp;quot;,&amp;quot;n&amp;quot;$1,&amp;quot;s&amp;quot;$1}' med_values.txt &amp;gt; do.cl&lt;br /&gt;
 cl &amp;lt; do.cl&lt;br /&gt;
    &lt;br /&gt;
 imcomb s@bdfFILTER.list final.fits comb=med offset=&amp;quot;wcs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Surface brightness limit ==&lt;br /&gt;
&lt;br /&gt;
 1. Calibrate the image taking non-saturated stars and not too faint stars: intercept and slope (TOPCAT with SDSS DR12 from Vizier)&lt;br /&gt;
 2. Calculate statistics inside at least 20 (empty, i.e. without objects) boxes of the size of 10&amp;quot; (for example if 1pix=0.396&amp;quot; than 10&amp;quot;~25 pix so boxes = 25 pix &amp;amp;times; 25 pix)&lt;br /&gt;
 3. Take the mean value of the standard deviation inside boxes and it's standard deviation&lt;br /&gt;
 4. Calculate SBmin and SBmax as: &lt;br /&gt;
    SBmax =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;-stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
    SBmin =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;+stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
 where &amp;lt;&amp;amp;sigma;&amp;gt; is the average standard deviation inside boxes and stdev(&amp;lt;&amp;amp;sigma;&amp;gt;) its standard deviation.&lt;br /&gt;
 5. Finally, 1 sigma surface brightness limit (SBlim) is given as:&lt;br /&gt;
    SBlim = (SBmin+SBmax)/2 +/- (SBmax-SBmin)/2&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=102</id>
		<title>CCD data reduction</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=102"/>
		<updated>2023-11-22T13:41:23Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* Flat field normalization */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic data reduction using IRAF ==&lt;br /&gt;
&lt;br /&gt;
Below is a bash script that creates lists of all images: biases, flats, darks and targets.&lt;br /&gt;
Special case of dark frames of 600sec that Milankovic generates is used&lt;br /&gt;
Last lines create ascii files with median values in flat frames that will be used&lt;br /&gt;
for their normalization.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;&lt;br /&gt;
The script creates reduce.cl IRAF script that should be run from iraf:&lt;br /&gt;
cl &amp;lt; reduce.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
rm *list&lt;br /&gt;
for frame in $(ls *fit); do&lt;br /&gt;
	filterType=$(gethead filter $frame)&lt;br /&gt;
	imageType=$(gethead imagetyp $frame)&lt;br /&gt;
	outFileName=$(echo $imageType | tr '[:upper:]' '[:lower:]')&lt;br /&gt;
	# test if DARK&lt;br /&gt;
	if [ ${imageType} = &amp;quot;DARK&amp;quot; ]; then&lt;br /&gt;
 		exptime=$(gethead exptime $frame | cut -d. -f1) &lt;br /&gt;
 		ls $frame &amp;gt;&amp;gt; ${outFileName}${exptime}&amp;quot;s&amp;quot;.list &lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${exptime}&amp;quot;s&amp;quot;.list&lt;br /&gt;
	else ls $frame &amp;gt;&amp;gt; ${outFileName}${filterType}.list&lt;br /&gt;
	fi&lt;br /&gt;
	# test if LIGHT and create additional lists&lt;br /&gt;
	if [ ${imageType} = &amp;quot;LIGHT&amp;quot; ]; then&lt;br /&gt;
	 	exptime=$(gethead exptime $frame | cut -d. -f1)&lt;br /&gt;
		echo $exptime &amp;gt;&amp;gt; exptime${filterType}.list&lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bdf&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bdf&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	 else if [ ${imageType} = &amp;quot;FLAT&amp;quot; ]; then&lt;br /&gt;
                echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
                echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;nbd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;nbd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	      fi&lt;br /&gt;
	 fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
# Create dark current corresponding to each light frame using exposure time&lt;br /&gt;
for exptime in $(ls exptime*.list); do &lt;br /&gt;
	filter=$(echo $exptime | sed -e s/exptime//g -e s/\.list//g);&lt;br /&gt;
	awk -v filter=${filter} '{print &amp;quot;dc&amp;quot;NR&amp;quot;_&amp;quot;filter&amp;quot;.fits&amp;quot;}' exptime${filter}.list  &amp;gt; dc${filter}.list&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce.cl ]; then rm reduce.cl; fi&lt;br /&gt;
echo &amp;quot;imdelete master_bias,dc_600s,dc_5s,dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bias.list master_bias comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark600s.list - master_bias @bdark600s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark5s.list - master_bias @bdark5s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark5s.list dc_5s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark600s.list dc_600s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl &lt;br /&gt;
echo &amp;quot;imarith dc_600s / 600 dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
&lt;br /&gt;
for flats in $(ls flat*list); do&lt;br /&gt;
        filterType=$(echo $flats | sed s/flat//g | cut -d. -f1)&lt;br /&gt;
        #echo $filterType&lt;br /&gt;
	echo &amp;quot;imarith @flat${filterType}.list - master_bias @bflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imarith @bflat${filterType}.list - dc_5s @bdflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imstat @bdflat${filterType}.list fields=\&amp;quot;image,midpt\&amp;quot; format- &amp;gt; norm${filterType}.txt&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Flat field normalization ==&lt;br /&gt;
&lt;br /&gt;
From terminal (bash):&lt;br /&gt;
&amp;lt;pre&amp;gt;  &lt;br /&gt;
for norm in $(ls norm*txt); do while read line; do echo $line | awk '! /^#/{print &amp;quot;imarith &amp;quot;$1&amp;quot; / &amp;quot;$2,&amp;quot;n&amp;quot;$1}'; done &amp;lt; $norm ; done &amp;gt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From terminal (IRAF):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cl &amp;lt; doflatnorm.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  BPM &amp;amp; object mask creation ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cat bpmask.cl&lt;br /&gt;
imstat dc_600s field=&amp;quot;image,mean,stddev&amp;quot; for- &amp;gt; hot.txt&lt;br /&gt;
imstat master_flat_FILTER fields=&amp;quot;image,mean&amp;quot; for- &amp;gt; cold.txt&lt;br /&gt;
cl &amp;lt; bpmask.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;gt; b) ? 1 : 0)\&amp;quot; hot&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;($2+3.*$3)*0.75}' hot.txt &amp;gt; hot.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;lt; b) ? 1 : 0)\&amp;quot; cold&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;$2*0.9}' cold.txt &amp;gt; cold.cl&lt;br /&gt;
cl &amp;lt; hot.cl&lt;br /&gt;
cl &amp;lt; cold.cl&lt;br /&gt;
# cat bpm.cl&lt;br /&gt;
imexpr &amp;quot;max(a,b)&amp;quot; bpmFILTER.pl a=hotFILTER.pl b=coldFILTER.pl&lt;br /&gt;
hedit @bdfFILTER.list BPM bpmFILTER.pl add+ ver- &lt;br /&gt;
# sed 's/FILTER/'${filter}'/g'  bpm.cl &amp;gt; dobpm.cl&lt;br /&gt;
cl &amp;lt; dobpm.cl&lt;br /&gt;
  &lt;br /&gt;
# Object masks creation&lt;br /&gt;
nproto&lt;br /&gt;
objmask @bdfFILTER.list @objbdfFILTER.list masks=&amp;quot;!BPM&amp;quot; hsig=2 lsig=2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Astrometry ==&lt;br /&gt;
 # cat astrometry.sh&lt;br /&gt;
 gethead OBJCTRA @bdfFILTER.list &amp;gt; name_ra.txt &lt;br /&gt;
 gethead OBJCTDEC @bdfFILTER.list | awk '{print $2,$3,$4}' &amp;gt; dec.txt&lt;br /&gt;
 paste -d&amp;quot; &amp;quot; name_ra.txt dec.txt | awk '{print $1,($2+$3/60+$4/3600)*15,$5+$6/60+$7/3600}' &amp;gt; astrometryFILTER.txt&lt;br /&gt;
 # sed s/FILTER/${filter}/g astrometry.sh  &amp;gt; astrometry${filter}.sh&lt;br /&gt;
 &lt;br /&gt;
 sh astrometry${filter}.sh&lt;br /&gt;
&lt;br /&gt;
  # This could be used:&lt;br /&gt;
  # cat komanda.sh&lt;br /&gt;
  solve-field img --ra imagera --dec imagedec --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center --wcs img.wcs &lt;br /&gt;
  ### The next command creates new files instead of just wcs binaries that can later be added to the header. It's a stand-alone command. And should be ignored.&lt;br /&gt;
  ### solve-field img --ra imagera --dec imagedec --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcsimg.fit  \ &lt;br /&gt;
  ###  -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy &lt;br /&gt;
  #while read line; do img=$(echo $line | awk '{print $1}'); imagera=$(echo $line | awk '{print $2}'); imagedec=$(echo $line | awk '{print $3}'); sed -e 's/img/'$img'/g' \ &lt;br /&gt;
 -e 's/imagera/'${imagera}'/g' -e 's/imagedec/'${imagedec}'/g' komanda.sh; done &amp;lt; astrometry${filter}.txt &amp;gt; doAstrometry.sh &lt;br /&gt;
 # Or this:&lt;br /&gt;
  awk '{print &amp;quot;solve-field &amp;quot;$1&amp;quot; --ra &amp;quot;$2&amp;quot; --dec &amp;quot;$3&amp;quot; --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcs&amp;quot;$1&amp;quot; \ &lt;br /&gt;
  -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy --wcs bla.wcs&amp;quot;}' astrometry${filter}.txt &amp;gt; doAstrometry.sh&lt;br /&gt;
&lt;br /&gt;
 # /bin/bash doAstrometry.sh&lt;br /&gt;
  #ls *wcs &amp;gt; wcs${filter}.list&lt;br /&gt;
  # echo &amp;quot;wcscopy @bdf${filter}.list @wcs${filter}.list ver-&amp;quot; &amp;gt; dowcs.cl&lt;br /&gt;
 cl &amp;lt; dowcs.cl&lt;br /&gt;
&lt;br /&gt;
== Supersky flat ==&lt;br /&gt;
 # Creation of super sky flat, normalization to each individual image median background and final stacking&lt;br /&gt;
 # cat stat.cl&lt;br /&gt;
 real mini&lt;br /&gt;
 real sky&lt;br /&gt;
 imstat(&amp;quot;img&amp;quot;,fields=&amp;quot;min&amp;quot;,lower=INDEF,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, mini)&lt;br /&gt;
 imcalc(input=&amp;quot;img,msk&amp;quot;,output=&amp;quot;skyimage&amp;quot;,equals=&amp;quot;if(im2==0.) then im1 else &amp;quot;//mini-0.001,ver-)&lt;br /&gt;
 imstat(&amp;quot;skyimage&amp;quot;,fields=&amp;quot;midpt&amp;quot;,lower=mini-0.001,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, sky)&lt;br /&gt;
 print(&amp;quot;img&amp;quot;,&amp;quot; &amp;quot;,sky)&lt;br /&gt;
 imarith(&amp;quot;img&amp;quot;,&amp;quot;/&amp;quot;,sky,&amp;quot;norm&amp;quot;)&lt;br /&gt;
 imdelete(&amp;quot;skyimage&amp;quot;,yes)&lt;br /&gt;
 # while read line; do img=$(echo $line | awk '{print $1}'); msk=&amp;quot;obj&amp;quot;${img%.*}.pl; rsky=&amp;quot;norm&amp;quot;${img}; cat stat.cl | sed -e 's/img/'${img}'/g' \&lt;br /&gt;
 -e 's/msk/'${msk}'/g'  -e 's/norm/'${rsky}'/g'; done &amp;lt; bdf${filter}.list &amp;gt;  bla.cl&lt;br /&gt;
 cl &amp;lt; bla.cl &amp;gt; med_values.txt&lt;br /&gt;
 # ls normbdf*fit &amp;gt; norm.list&lt;br /&gt;
 imcomb @norm.list norm.fits comb=med masktype=&amp;quot;!OBJMASK&amp;quot; maskval=0&lt;br /&gt;
 # awk '{print &amp;quot;imarith norm.fits * &amp;quot;$2,&amp;quot; n&amp;quot;$1}' med_values.txt &amp;gt; donorm.cl&lt;br /&gt;
 cl &amp;lt; donorm.cl&lt;br /&gt;
 # awk '{print &amp;quot;imarith&amp;quot;,$1,&amp;quot;-&amp;quot;,&amp;quot;n&amp;quot;$1,&amp;quot;s&amp;quot;$1}' med_values.txt &amp;gt; do.cl&lt;br /&gt;
 cl &amp;lt; do.cl&lt;br /&gt;
    &lt;br /&gt;
 imcomb s@bdfFILTER.list final.fits comb=med offset=&amp;quot;wcs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Surface brightness limit ==&lt;br /&gt;
&lt;br /&gt;
 1. Calibrate the image taking non-saturated stars and not too faint stars: intercept and slope (TOPCAT with SDSS DR12 from Vizier)&lt;br /&gt;
 2. Calculate statistics inside at least 20 (empty, i.e. without objects) boxes of the size of 10&amp;quot; (for example if 1pix=0.396&amp;quot; than 10&amp;quot;~25 pix so boxes = 25 pix &amp;amp;times; 25 pix)&lt;br /&gt;
 3. Take the mean value of the standard deviation inside boxes and it's standard deviation&lt;br /&gt;
 4. Calculate SBmin and SBmax as: &lt;br /&gt;
    SBmax =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;-stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
    SBmin =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;+stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
 where &amp;lt;&amp;amp;sigma;&amp;gt; is the average standard deviation inside boxes and stdev(&amp;lt;&amp;amp;sigma;&amp;gt;) its standard deviation.&lt;br /&gt;
 5. Finally, 1 sigma surface brightness limit (SBlim) is given as:&lt;br /&gt;
    SBlim = (SBmin+SBmax)/2 +/- (SBmax-SBmin)/2&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=101</id>
		<title>CCD data reduction</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=101"/>
		<updated>2023-11-22T13:40:15Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* Basic data reduction using IRAF */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic data reduction using IRAF ==&lt;br /&gt;
&lt;br /&gt;
Below is a bash script that creates lists of all images: biases, flats, darks and targets.&lt;br /&gt;
Special case of dark frames of 600sec that Milankovic generates is used&lt;br /&gt;
Last lines create ascii files with median values in flat frames that will be used&lt;br /&gt;
for their normalization.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;&lt;br /&gt;
The script creates reduce.cl IRAF script that should be run from iraf:&lt;br /&gt;
cl &amp;lt; reduce.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
rm *list&lt;br /&gt;
for frame in $(ls *fit); do&lt;br /&gt;
	filterType=$(gethead filter $frame)&lt;br /&gt;
	imageType=$(gethead imagetyp $frame)&lt;br /&gt;
	outFileName=$(echo $imageType | tr '[:upper:]' '[:lower:]')&lt;br /&gt;
	# test if DARK&lt;br /&gt;
	if [ ${imageType} = &amp;quot;DARK&amp;quot; ]; then&lt;br /&gt;
 		exptime=$(gethead exptime $frame | cut -d. -f1) &lt;br /&gt;
 		ls $frame &amp;gt;&amp;gt; ${outFileName}${exptime}&amp;quot;s&amp;quot;.list &lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${exptime}&amp;quot;s&amp;quot;.list&lt;br /&gt;
	else ls $frame &amp;gt;&amp;gt; ${outFileName}${filterType}.list&lt;br /&gt;
	fi&lt;br /&gt;
	# test if LIGHT and create additional lists&lt;br /&gt;
	if [ ${imageType} = &amp;quot;LIGHT&amp;quot; ]; then&lt;br /&gt;
	 	exptime=$(gethead exptime $frame | cut -d. -f1)&lt;br /&gt;
		echo $exptime &amp;gt;&amp;gt; exptime${filterType}.list&lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bdf&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bdf&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	 else if [ ${imageType} = &amp;quot;FLAT&amp;quot; ]; then&lt;br /&gt;
                echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
                echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;nbd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;nbd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	      fi&lt;br /&gt;
	 fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
# Create dark current corresponding to each light frame using exposure time&lt;br /&gt;
for exptime in $(ls exptime*.list); do &lt;br /&gt;
	filter=$(echo $exptime | sed -e s/exptime//g -e s/\.list//g);&lt;br /&gt;
	awk -v filter=${filter} '{print &amp;quot;dc&amp;quot;NR&amp;quot;_&amp;quot;filter&amp;quot;.fits&amp;quot;}' exptime${filter}.list  &amp;gt; dc${filter}.list&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce.cl ]; then rm reduce.cl; fi&lt;br /&gt;
echo &amp;quot;imdelete master_bias,dc_600s,dc_5s,dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bias.list master_bias comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark600s.list - master_bias @bdark600s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark5s.list - master_bias @bdark5s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark5s.list dc_5s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark600s.list dc_600s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl &lt;br /&gt;
echo &amp;quot;imarith dc_600s / 600 dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
&lt;br /&gt;
for flats in $(ls flat*list); do&lt;br /&gt;
        filterType=$(echo $flats | sed s/flat//g | cut -d. -f1)&lt;br /&gt;
        #echo $filterType&lt;br /&gt;
	echo &amp;quot;imarith @flat${filterType}.list - master_bias @bflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imarith @bflat${filterType}.list - dc_5s @bdflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imstat @bdflat${filterType}.list fields=\&amp;quot;image,midpt\&amp;quot; format- &amp;gt; norm${filterType}.txt&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Flat field normalization ==&lt;br /&gt;
&lt;br /&gt;
  for norm in $(ls norm*txt); do while read line; do echo $line | awk '! /^#/{print &amp;quot;imarith &amp;quot;$1&amp;quot; / &amp;quot;$2,&amp;quot;n&amp;quot;$1}'; done &amp;lt; $norm ; done &amp;gt; doflatnormNew.cl&lt;br /&gt;
&lt;br /&gt;
==  BPM &amp;amp; object mask creation ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cat bpmask.cl&lt;br /&gt;
imstat dc_600s field=&amp;quot;image,mean,stddev&amp;quot; for- &amp;gt; hot.txt&lt;br /&gt;
imstat master_flat_FILTER fields=&amp;quot;image,mean&amp;quot; for- &amp;gt; cold.txt&lt;br /&gt;
cl &amp;lt; bpmask.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;gt; b) ? 1 : 0)\&amp;quot; hot&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;($2+3.*$3)*0.75}' hot.txt &amp;gt; hot.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;lt; b) ? 1 : 0)\&amp;quot; cold&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;$2*0.9}' cold.txt &amp;gt; cold.cl&lt;br /&gt;
cl &amp;lt; hot.cl&lt;br /&gt;
cl &amp;lt; cold.cl&lt;br /&gt;
# cat bpm.cl&lt;br /&gt;
imexpr &amp;quot;max(a,b)&amp;quot; bpmFILTER.pl a=hotFILTER.pl b=coldFILTER.pl&lt;br /&gt;
hedit @bdfFILTER.list BPM bpmFILTER.pl add+ ver- &lt;br /&gt;
# sed 's/FILTER/'${filter}'/g'  bpm.cl &amp;gt; dobpm.cl&lt;br /&gt;
cl &amp;lt; dobpm.cl&lt;br /&gt;
  &lt;br /&gt;
# Object masks creation&lt;br /&gt;
nproto&lt;br /&gt;
objmask @bdfFILTER.list @objbdfFILTER.list masks=&amp;quot;!BPM&amp;quot; hsig=2 lsig=2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Astrometry ==&lt;br /&gt;
 # cat astrometry.sh&lt;br /&gt;
 gethead OBJCTRA @bdfFILTER.list &amp;gt; name_ra.txt &lt;br /&gt;
 gethead OBJCTDEC @bdfFILTER.list | awk '{print $2,$3,$4}' &amp;gt; dec.txt&lt;br /&gt;
 paste -d&amp;quot; &amp;quot; name_ra.txt dec.txt | awk '{print $1,($2+$3/60+$4/3600)*15,$5+$6/60+$7/3600}' &amp;gt; astrometryFILTER.txt&lt;br /&gt;
 # sed s/FILTER/${filter}/g astrometry.sh  &amp;gt; astrometry${filter}.sh&lt;br /&gt;
 &lt;br /&gt;
 sh astrometry${filter}.sh&lt;br /&gt;
&lt;br /&gt;
  # This could be used:&lt;br /&gt;
  # cat komanda.sh&lt;br /&gt;
  solve-field img --ra imagera --dec imagedec --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center --wcs img.wcs &lt;br /&gt;
  ### The next command creates new files instead of just wcs binaries that can later be added to the header. It's a stand-alone command. And should be ignored.&lt;br /&gt;
  ### solve-field img --ra imagera --dec imagedec --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcsimg.fit  \ &lt;br /&gt;
  ###  -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy &lt;br /&gt;
  #while read line; do img=$(echo $line | awk '{print $1}'); imagera=$(echo $line | awk '{print $2}'); imagedec=$(echo $line | awk '{print $3}'); sed -e 's/img/'$img'/g' \ &lt;br /&gt;
 -e 's/imagera/'${imagera}'/g' -e 's/imagedec/'${imagedec}'/g' komanda.sh; done &amp;lt; astrometry${filter}.txt &amp;gt; doAstrometry.sh &lt;br /&gt;
 # Or this:&lt;br /&gt;
  awk '{print &amp;quot;solve-field &amp;quot;$1&amp;quot; --ra &amp;quot;$2&amp;quot; --dec &amp;quot;$3&amp;quot; --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcs&amp;quot;$1&amp;quot; \ &lt;br /&gt;
  -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy --wcs bla.wcs&amp;quot;}' astrometry${filter}.txt &amp;gt; doAstrometry.sh&lt;br /&gt;
&lt;br /&gt;
 # /bin/bash doAstrometry.sh&lt;br /&gt;
  #ls *wcs &amp;gt; wcs${filter}.list&lt;br /&gt;
  # echo &amp;quot;wcscopy @bdf${filter}.list @wcs${filter}.list ver-&amp;quot; &amp;gt; dowcs.cl&lt;br /&gt;
 cl &amp;lt; dowcs.cl&lt;br /&gt;
&lt;br /&gt;
== Supersky flat ==&lt;br /&gt;
 # Creation of super sky flat, normalization to each individual image median background and final stacking&lt;br /&gt;
 # cat stat.cl&lt;br /&gt;
 real mini&lt;br /&gt;
 real sky&lt;br /&gt;
 imstat(&amp;quot;img&amp;quot;,fields=&amp;quot;min&amp;quot;,lower=INDEF,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, mini)&lt;br /&gt;
 imcalc(input=&amp;quot;img,msk&amp;quot;,output=&amp;quot;skyimage&amp;quot;,equals=&amp;quot;if(im2==0.) then im1 else &amp;quot;//mini-0.001,ver-)&lt;br /&gt;
 imstat(&amp;quot;skyimage&amp;quot;,fields=&amp;quot;midpt&amp;quot;,lower=mini-0.001,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, sky)&lt;br /&gt;
 print(&amp;quot;img&amp;quot;,&amp;quot; &amp;quot;,sky)&lt;br /&gt;
 imarith(&amp;quot;img&amp;quot;,&amp;quot;/&amp;quot;,sky,&amp;quot;norm&amp;quot;)&lt;br /&gt;
 imdelete(&amp;quot;skyimage&amp;quot;,yes)&lt;br /&gt;
 # while read line; do img=$(echo $line | awk '{print $1}'); msk=&amp;quot;obj&amp;quot;${img%.*}.pl; rsky=&amp;quot;norm&amp;quot;${img}; cat stat.cl | sed -e 's/img/'${img}'/g' \&lt;br /&gt;
 -e 's/msk/'${msk}'/g'  -e 's/norm/'${rsky}'/g'; done &amp;lt; bdf${filter}.list &amp;gt;  bla.cl&lt;br /&gt;
 cl &amp;lt; bla.cl &amp;gt; med_values.txt&lt;br /&gt;
 # ls normbdf*fit &amp;gt; norm.list&lt;br /&gt;
 imcomb @norm.list norm.fits comb=med masktype=&amp;quot;!OBJMASK&amp;quot; maskval=0&lt;br /&gt;
 # awk '{print &amp;quot;imarith norm.fits * &amp;quot;$2,&amp;quot; n&amp;quot;$1}' med_values.txt &amp;gt; donorm.cl&lt;br /&gt;
 cl &amp;lt; donorm.cl&lt;br /&gt;
 # awk '{print &amp;quot;imarith&amp;quot;,$1,&amp;quot;-&amp;quot;,&amp;quot;n&amp;quot;$1,&amp;quot;s&amp;quot;$1}' med_values.txt &amp;gt; do.cl&lt;br /&gt;
 cl &amp;lt; do.cl&lt;br /&gt;
    &lt;br /&gt;
 imcomb s@bdfFILTER.list final.fits comb=med offset=&amp;quot;wcs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Surface brightness limit ==&lt;br /&gt;
&lt;br /&gt;
 1. Calibrate the image taking non-saturated stars and not too faint stars: intercept and slope (TOPCAT with SDSS DR12 from Vizier)&lt;br /&gt;
 2. Calculate statistics inside at least 20 (empty, i.e. without objects) boxes of the size of 10&amp;quot; (for example if 1pix=0.396&amp;quot; than 10&amp;quot;~25 pix so boxes = 25 pix &amp;amp;times; 25 pix)&lt;br /&gt;
 3. Take the mean value of the standard deviation inside boxes and it's standard deviation&lt;br /&gt;
 4. Calculate SBmin and SBmax as: &lt;br /&gt;
    SBmax =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;-stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
    SBmin =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;+stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
 where &amp;lt;&amp;amp;sigma;&amp;gt; is the average standard deviation inside boxes and stdev(&amp;lt;&amp;amp;sigma;&amp;gt;) its standard deviation.&lt;br /&gt;
 5. Finally, 1 sigma surface brightness limit (SBlim) is given as:&lt;br /&gt;
    SBlim = (SBmin+SBmax)/2 +/- (SBmax-SBmin)/2&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=100</id>
		<title>CCD data reduction</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=100"/>
		<updated>2023-11-22T13:32:35Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* Basic data reduction using IRAF */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic data reduction using IRAF ==&lt;br /&gt;
&lt;br /&gt;
Below is a bash script that creates lists of all images: biases, flats, darks and targets.&lt;br /&gt;
Special case of dark frames of 600sec that Milankovic generates is used&lt;br /&gt;
Last lines create ascii files with median values in flat frames that will be used&lt;br /&gt;
for their normalization.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt;&lt;br /&gt;
The script creates reduce.cl IRAF script that should be run from iraf:&lt;br /&gt;
cl &amp;lt; reduce.cl&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
rm *list&lt;br /&gt;
for frame in $(ls *fit); do&lt;br /&gt;
	filterType=$(gethead filter $frame)&lt;br /&gt;
	imageType=$(gethead imagetyp $frame)&lt;br /&gt;
	outFileName=$(echo $imageType | tr '[:upper:]' '[:lower:]')&lt;br /&gt;
	# test if DARK&lt;br /&gt;
	if [ ${imageType} = &amp;quot;DARK&amp;quot; ]; then&lt;br /&gt;
 		exptime=$(gethead exptime $frame | cut -d. -f1) &lt;br /&gt;
 		ls $frame &amp;gt;&amp;gt; ${outFileName}${exptime}&amp;quot;s&amp;quot;.list &lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${exptime}&amp;quot;s&amp;quot;.list&lt;br /&gt;
	else ls $frame &amp;gt;&amp;gt; ${outFileName}${filterType}.list&lt;br /&gt;
	fi&lt;br /&gt;
	# test if LIGHT and create additional lists&lt;br /&gt;
	if [ ${imageType} = &amp;quot;LIGHT&amp;quot; ]; then&lt;br /&gt;
	 	exptime=$(gethead exptime $frame | cut -d. -f1)&lt;br /&gt;
		echo $exptime &amp;gt;&amp;gt; exptime${filterType}.list&lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bdf&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bdf&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	 else if [ ${imageType} = &amp;quot;FLAT&amp;quot; ]; then&lt;br /&gt;
                echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
                echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;nbd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;nbd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	      fi&lt;br /&gt;
	 fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
# Create dark current corresponding to each light frame using exposure time&lt;br /&gt;
for exptime in $(ls exptime*.list); do &lt;br /&gt;
	filter=$(echo $exptime | sed -e s/exptime//g -e s/\.list//g);&lt;br /&gt;
	awk -v filter=${filter} '{print &amp;quot;dc&amp;quot;NR&amp;quot;_&amp;quot;filter&amp;quot;.fits&amp;quot;}' exptime${filter}.list  &amp;gt; dc${filter}.list&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce.cl ]; then rm reduce.cl; fi&lt;br /&gt;
echo &amp;quot;imdelete master_bias,dc_600s,dc_5s,dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bias.list master_bias comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark600s.list - master_bias @bdark600s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark5s.list - master_bias @bdark5s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark5s.list dc_5s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark600s.list dc_600s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl &lt;br /&gt;
echo &amp;quot;imarith dc_600s / 600 dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
&lt;br /&gt;
for flats in $(ls flat*list); do&lt;br /&gt;
        filterType=$(echo $flats | sed s/flat//g | cut -d. -f1)&lt;br /&gt;
        #echo $filterType&lt;br /&gt;
	echo &amp;quot;imarith @flat${filterType}.list - master_bias @bflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imarith @bflat${filterType}.list - dc_5s @bdflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imstat @bdflat${filterType}.list fields=\&amp;quot;image,midpt\&amp;quot; format- &amp;gt; norm${filterType}.txt&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  BPM &amp;amp; object mask creation ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cat bpmask.cl&lt;br /&gt;
imstat dc_600s field=&amp;quot;image,mean,stddev&amp;quot; for- &amp;gt; hot.txt&lt;br /&gt;
imstat master_flat_FILTER fields=&amp;quot;image,mean&amp;quot; for- &amp;gt; cold.txt&lt;br /&gt;
cl &amp;lt; bpmask.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;gt; b) ? 1 : 0)\&amp;quot; hot&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;($2+3.*$3)*0.75}' hot.txt &amp;gt; hot.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;lt; b) ? 1 : 0)\&amp;quot; cold&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;$2*0.9}' cold.txt &amp;gt; cold.cl&lt;br /&gt;
cl &amp;lt; hot.cl&lt;br /&gt;
cl &amp;lt; cold.cl&lt;br /&gt;
# cat bpm.cl&lt;br /&gt;
imexpr &amp;quot;max(a,b)&amp;quot; bpmFILTER.pl a=hotFILTER.pl b=coldFILTER.pl&lt;br /&gt;
hedit @bdfFILTER.list BPM bpmFILTER.pl add+ ver- &lt;br /&gt;
# sed 's/FILTER/'${filter}'/g'  bpm.cl &amp;gt; dobpm.cl&lt;br /&gt;
cl &amp;lt; dobpm.cl&lt;br /&gt;
  &lt;br /&gt;
# Object masks creation&lt;br /&gt;
nproto&lt;br /&gt;
objmask @bdfFILTER.list @objbdfFILTER.list masks=&amp;quot;!BPM&amp;quot; hsig=2 lsig=2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Astrometry ==&lt;br /&gt;
 # cat astrometry.sh&lt;br /&gt;
 gethead OBJCTRA @bdfFILTER.list &amp;gt; name_ra.txt &lt;br /&gt;
 gethead OBJCTDEC @bdfFILTER.list | awk '{print $2,$3,$4}' &amp;gt; dec.txt&lt;br /&gt;
 paste -d&amp;quot; &amp;quot; name_ra.txt dec.txt | awk '{print $1,($2+$3/60+$4/3600)*15,$5+$6/60+$7/3600}' &amp;gt; astrometryFILTER.txt&lt;br /&gt;
 # sed s/FILTER/${filter}/g astrometry.sh  &amp;gt; astrometry${filter}.sh&lt;br /&gt;
 &lt;br /&gt;
 sh astrometry${filter}.sh&lt;br /&gt;
&lt;br /&gt;
  # This could be used:&lt;br /&gt;
  # cat komanda.sh&lt;br /&gt;
  solve-field img --ra imagera --dec imagedec --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center --wcs img.wcs &lt;br /&gt;
  ### The next command creates new files instead of just wcs binaries that can later be added to the header. It's a stand-alone command. And should be ignored.&lt;br /&gt;
  ### solve-field img --ra imagera --dec imagedec --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcsimg.fit  \ &lt;br /&gt;
  ###  -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy &lt;br /&gt;
  #while read line; do img=$(echo $line | awk '{print $1}'); imagera=$(echo $line | awk '{print $2}'); imagedec=$(echo $line | awk '{print $3}'); sed -e 's/img/'$img'/g' \ &lt;br /&gt;
 -e 's/imagera/'${imagera}'/g' -e 's/imagedec/'${imagedec}'/g' komanda.sh; done &amp;lt; astrometry${filter}.txt &amp;gt; doAstrometry.sh &lt;br /&gt;
 # Or this:&lt;br /&gt;
  awk '{print &amp;quot;solve-field &amp;quot;$1&amp;quot; --ra &amp;quot;$2&amp;quot; --dec &amp;quot;$3&amp;quot; --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcs&amp;quot;$1&amp;quot; \ &lt;br /&gt;
  -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy --wcs bla.wcs&amp;quot;}' astrometry${filter}.txt &amp;gt; doAstrometry.sh&lt;br /&gt;
&lt;br /&gt;
 # /bin/bash doAstrometry.sh&lt;br /&gt;
  #ls *wcs &amp;gt; wcs${filter}.list&lt;br /&gt;
  # echo &amp;quot;wcscopy @bdf${filter}.list @wcs${filter}.list ver-&amp;quot; &amp;gt; dowcs.cl&lt;br /&gt;
 cl &amp;lt; dowcs.cl&lt;br /&gt;
&lt;br /&gt;
== Supersky flat ==&lt;br /&gt;
 # Creation of super sky flat, normalization to each individual image median background and final stacking&lt;br /&gt;
 # cat stat.cl&lt;br /&gt;
 real mini&lt;br /&gt;
 real sky&lt;br /&gt;
 imstat(&amp;quot;img&amp;quot;,fields=&amp;quot;min&amp;quot;,lower=INDEF,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, mini)&lt;br /&gt;
 imcalc(input=&amp;quot;img,msk&amp;quot;,output=&amp;quot;skyimage&amp;quot;,equals=&amp;quot;if(im2==0.) then im1 else &amp;quot;//mini-0.001,ver-)&lt;br /&gt;
 imstat(&amp;quot;skyimage&amp;quot;,fields=&amp;quot;midpt&amp;quot;,lower=mini-0.001,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, sky)&lt;br /&gt;
 print(&amp;quot;img&amp;quot;,&amp;quot; &amp;quot;,sky)&lt;br /&gt;
 imarith(&amp;quot;img&amp;quot;,&amp;quot;/&amp;quot;,sky,&amp;quot;norm&amp;quot;)&lt;br /&gt;
 imdelete(&amp;quot;skyimage&amp;quot;,yes)&lt;br /&gt;
 # while read line; do img=$(echo $line | awk '{print $1}'); msk=&amp;quot;obj&amp;quot;${img%.*}.pl; rsky=&amp;quot;norm&amp;quot;${img}; cat stat.cl | sed -e 's/img/'${img}'/g' \&lt;br /&gt;
 -e 's/msk/'${msk}'/g'  -e 's/norm/'${rsky}'/g'; done &amp;lt; bdf${filter}.list &amp;gt;  bla.cl&lt;br /&gt;
 cl &amp;lt; bla.cl &amp;gt; med_values.txt&lt;br /&gt;
 # ls normbdf*fit &amp;gt; norm.list&lt;br /&gt;
 imcomb @norm.list norm.fits comb=med masktype=&amp;quot;!OBJMASK&amp;quot; maskval=0&lt;br /&gt;
 # awk '{print &amp;quot;imarith norm.fits * &amp;quot;$2,&amp;quot; n&amp;quot;$1}' med_values.txt &amp;gt; donorm.cl&lt;br /&gt;
 cl &amp;lt; donorm.cl&lt;br /&gt;
 # awk '{print &amp;quot;imarith&amp;quot;,$1,&amp;quot;-&amp;quot;,&amp;quot;n&amp;quot;$1,&amp;quot;s&amp;quot;$1}' med_values.txt &amp;gt; do.cl&lt;br /&gt;
 cl &amp;lt; do.cl&lt;br /&gt;
    &lt;br /&gt;
 imcomb s@bdfFILTER.list final.fits comb=med offset=&amp;quot;wcs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Surface brightness limit ==&lt;br /&gt;
&lt;br /&gt;
 1. Calibrate the image taking non-saturated stars and not too faint stars: intercept and slope (TOPCAT with SDSS DR12 from Vizier)&lt;br /&gt;
 2. Calculate statistics inside at least 20 (empty, i.e. without objects) boxes of the size of 10&amp;quot; (for example if 1pix=0.396&amp;quot; than 10&amp;quot;~25 pix so boxes = 25 pix &amp;amp;times; 25 pix)&lt;br /&gt;
 3. Take the mean value of the standard deviation inside boxes and it's standard deviation&lt;br /&gt;
 4. Calculate SBmin and SBmax as: &lt;br /&gt;
    SBmax =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;-stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
    SBmin =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;+stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
 where &amp;lt;&amp;amp;sigma;&amp;gt; is the average standard deviation inside boxes and stdev(&amp;lt;&amp;amp;sigma;&amp;gt;) its standard deviation.&lt;br /&gt;
 5. Finally, 1 sigma surface brightness limit (SBlim) is given as:&lt;br /&gt;
    SBlim = (SBmin+SBmax)/2 +/- (SBmax-SBmin)/2&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=99</id>
		<title>CCD data reduction</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=99"/>
		<updated>2023-11-22T13:31:55Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* Basic data reduction using IRAF */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic data reduction using IRAF ==&lt;br /&gt;
&lt;br /&gt;
Below is a bash script that creates lists of all images: biases, flats, darks and targets.&lt;br /&gt;
Special case of dark frames of 600sec that Milankovic generates is used&lt;br /&gt;
Last lines create ascii files with median values in flat frames that will be used&lt;br /&gt;
for their normalization.&lt;br /&gt;
&lt;br /&gt;
 The script creates reduce.cl IRAF script that should be run from iraf:&lt;br /&gt;
 cl &amp;lt; reduce.cl&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
rm *list&lt;br /&gt;
for frame in $(ls *fit); do&lt;br /&gt;
	filterType=$(gethead filter $frame)&lt;br /&gt;
	imageType=$(gethead imagetyp $frame)&lt;br /&gt;
	outFileName=$(echo $imageType | tr '[:upper:]' '[:lower:]')&lt;br /&gt;
	# test if DARK&lt;br /&gt;
	if [ ${imageType} = &amp;quot;DARK&amp;quot; ]; then&lt;br /&gt;
 		exptime=$(gethead exptime $frame | cut -d. -f1) &lt;br /&gt;
 		ls $frame &amp;gt;&amp;gt; ${outFileName}${exptime}&amp;quot;s&amp;quot;.list &lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${exptime}&amp;quot;s&amp;quot;.list&lt;br /&gt;
	else ls $frame &amp;gt;&amp;gt; ${outFileName}${filterType}.list&lt;br /&gt;
	fi&lt;br /&gt;
	# test if LIGHT and create additional lists&lt;br /&gt;
	if [ ${imageType} = &amp;quot;LIGHT&amp;quot; ]; then&lt;br /&gt;
	 	exptime=$(gethead exptime $frame | cut -d. -f1)&lt;br /&gt;
		echo $exptime &amp;gt;&amp;gt; exptime${filterType}.list&lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bdf&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bdf&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	 else if [ ${imageType} = &amp;quot;FLAT&amp;quot; ]; then&lt;br /&gt;
                echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
                echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;nbd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;nbd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	      fi&lt;br /&gt;
	 fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
# Create dark current corresponding to each light frame using exposure time&lt;br /&gt;
for exptime in $(ls exptime*.list); do &lt;br /&gt;
	filter=$(echo $exptime | sed -e s/exptime//g -e s/\.list//g);&lt;br /&gt;
	awk -v filter=${filter} '{print &amp;quot;dc&amp;quot;NR&amp;quot;_&amp;quot;filter&amp;quot;.fits&amp;quot;}' exptime${filter}.list  &amp;gt; dc${filter}.list&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce.cl ]; then rm reduce.cl; fi&lt;br /&gt;
echo &amp;quot;imdelete master_bias,dc_600s,dc_5s,dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bias.list master_bias comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark600s.list - master_bias @bdark600s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark5s.list - master_bias @bdark5s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark5s.list dc_5s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark600s.list dc_600s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl &lt;br /&gt;
echo &amp;quot;imarith dc_600s / 600 dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
&lt;br /&gt;
for flats in $(ls flat*list); do&lt;br /&gt;
        filterType=$(echo $flats | sed s/flat//g | cut -d. -f1)&lt;br /&gt;
        #echo $filterType&lt;br /&gt;
	echo &amp;quot;imarith @flat${filterType}.list - master_bias @bflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imarith @bflat${filterType}.list - dc_5s @bdflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imstat @bdflat${filterType}.list fields=\&amp;quot;image,midpt\&amp;quot; format- &amp;gt; norm${filterType}.txt&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  BPM &amp;amp; object mask creation ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cat bpmask.cl&lt;br /&gt;
imstat dc_600s field=&amp;quot;image,mean,stddev&amp;quot; for- &amp;gt; hot.txt&lt;br /&gt;
imstat master_flat_FILTER fields=&amp;quot;image,mean&amp;quot; for- &amp;gt; cold.txt&lt;br /&gt;
cl &amp;lt; bpmask.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;gt; b) ? 1 : 0)\&amp;quot; hot&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;($2+3.*$3)*0.75}' hot.txt &amp;gt; hot.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;lt; b) ? 1 : 0)\&amp;quot; cold&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;$2*0.9}' cold.txt &amp;gt; cold.cl&lt;br /&gt;
cl &amp;lt; hot.cl&lt;br /&gt;
cl &amp;lt; cold.cl&lt;br /&gt;
# cat bpm.cl&lt;br /&gt;
imexpr &amp;quot;max(a,b)&amp;quot; bpmFILTER.pl a=hotFILTER.pl b=coldFILTER.pl&lt;br /&gt;
hedit @bdfFILTER.list BPM bpmFILTER.pl add+ ver- &lt;br /&gt;
# sed 's/FILTER/'${filter}'/g'  bpm.cl &amp;gt; dobpm.cl&lt;br /&gt;
cl &amp;lt; dobpm.cl&lt;br /&gt;
  &lt;br /&gt;
# Object masks creation&lt;br /&gt;
nproto&lt;br /&gt;
objmask @bdfFILTER.list @objbdfFILTER.list masks=&amp;quot;!BPM&amp;quot; hsig=2 lsig=2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Astrometry ==&lt;br /&gt;
 # cat astrometry.sh&lt;br /&gt;
 gethead OBJCTRA @bdfFILTER.list &amp;gt; name_ra.txt &lt;br /&gt;
 gethead OBJCTDEC @bdfFILTER.list | awk '{print $2,$3,$4}' &amp;gt; dec.txt&lt;br /&gt;
 paste -d&amp;quot; &amp;quot; name_ra.txt dec.txt | awk '{print $1,($2+$3/60+$4/3600)*15,$5+$6/60+$7/3600}' &amp;gt; astrometryFILTER.txt&lt;br /&gt;
 # sed s/FILTER/${filter}/g astrometry.sh  &amp;gt; astrometry${filter}.sh&lt;br /&gt;
 &lt;br /&gt;
 sh astrometry${filter}.sh&lt;br /&gt;
&lt;br /&gt;
  # This could be used:&lt;br /&gt;
  # cat komanda.sh&lt;br /&gt;
  solve-field img --ra imagera --dec imagedec --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center --wcs img.wcs &lt;br /&gt;
  ### The next command creates new files instead of just wcs binaries that can later be added to the header. It's a stand-alone command. And should be ignored.&lt;br /&gt;
  ### solve-field img --ra imagera --dec imagedec --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcsimg.fit  \ &lt;br /&gt;
  ###  -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy &lt;br /&gt;
  #while read line; do img=$(echo $line | awk '{print $1}'); imagera=$(echo $line | awk '{print $2}'); imagedec=$(echo $line | awk '{print $3}'); sed -e 's/img/'$img'/g' \ &lt;br /&gt;
 -e 's/imagera/'${imagera}'/g' -e 's/imagedec/'${imagedec}'/g' komanda.sh; done &amp;lt; astrometry${filter}.txt &amp;gt; doAstrometry.sh &lt;br /&gt;
 # Or this:&lt;br /&gt;
  awk '{print &amp;quot;solve-field &amp;quot;$1&amp;quot; --ra &amp;quot;$2&amp;quot; --dec &amp;quot;$3&amp;quot; --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcs&amp;quot;$1&amp;quot; \ &lt;br /&gt;
  -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy --wcs bla.wcs&amp;quot;}' astrometry${filter}.txt &amp;gt; doAstrometry.sh&lt;br /&gt;
&lt;br /&gt;
 # /bin/bash doAstrometry.sh&lt;br /&gt;
  #ls *wcs &amp;gt; wcs${filter}.list&lt;br /&gt;
  # echo &amp;quot;wcscopy @bdf${filter}.list @wcs${filter}.list ver-&amp;quot; &amp;gt; dowcs.cl&lt;br /&gt;
 cl &amp;lt; dowcs.cl&lt;br /&gt;
&lt;br /&gt;
== Supersky flat ==&lt;br /&gt;
 # Creation of super sky flat, normalization to each individual image median background and final stacking&lt;br /&gt;
 # cat stat.cl&lt;br /&gt;
 real mini&lt;br /&gt;
 real sky&lt;br /&gt;
 imstat(&amp;quot;img&amp;quot;,fields=&amp;quot;min&amp;quot;,lower=INDEF,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, mini)&lt;br /&gt;
 imcalc(input=&amp;quot;img,msk&amp;quot;,output=&amp;quot;skyimage&amp;quot;,equals=&amp;quot;if(im2==0.) then im1 else &amp;quot;//mini-0.001,ver-)&lt;br /&gt;
 imstat(&amp;quot;skyimage&amp;quot;,fields=&amp;quot;midpt&amp;quot;,lower=mini-0.001,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, sky)&lt;br /&gt;
 print(&amp;quot;img&amp;quot;,&amp;quot; &amp;quot;,sky)&lt;br /&gt;
 imarith(&amp;quot;img&amp;quot;,&amp;quot;/&amp;quot;,sky,&amp;quot;norm&amp;quot;)&lt;br /&gt;
 imdelete(&amp;quot;skyimage&amp;quot;,yes)&lt;br /&gt;
 # while read line; do img=$(echo $line | awk '{print $1}'); msk=&amp;quot;obj&amp;quot;${img%.*}.pl; rsky=&amp;quot;norm&amp;quot;${img}; cat stat.cl | sed -e 's/img/'${img}'/g' \&lt;br /&gt;
 -e 's/msk/'${msk}'/g'  -e 's/norm/'${rsky}'/g'; done &amp;lt; bdf${filter}.list &amp;gt;  bla.cl&lt;br /&gt;
 cl &amp;lt; bla.cl &amp;gt; med_values.txt&lt;br /&gt;
 # ls normbdf*fit &amp;gt; norm.list&lt;br /&gt;
 imcomb @norm.list norm.fits comb=med masktype=&amp;quot;!OBJMASK&amp;quot; maskval=0&lt;br /&gt;
 # awk '{print &amp;quot;imarith norm.fits * &amp;quot;$2,&amp;quot; n&amp;quot;$1}' med_values.txt &amp;gt; donorm.cl&lt;br /&gt;
 cl &amp;lt; donorm.cl&lt;br /&gt;
 # awk '{print &amp;quot;imarith&amp;quot;,$1,&amp;quot;-&amp;quot;,&amp;quot;n&amp;quot;$1,&amp;quot;s&amp;quot;$1}' med_values.txt &amp;gt; do.cl&lt;br /&gt;
 cl &amp;lt; do.cl&lt;br /&gt;
    &lt;br /&gt;
 imcomb s@bdfFILTER.list final.fits comb=med offset=&amp;quot;wcs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Surface brightness limit ==&lt;br /&gt;
&lt;br /&gt;
 1. Calibrate the image taking non-saturated stars and not too faint stars: intercept and slope (TOPCAT with SDSS DR12 from Vizier)&lt;br /&gt;
 2. Calculate statistics inside at least 20 (empty, i.e. without objects) boxes of the size of 10&amp;quot; (for example if 1pix=0.396&amp;quot; than 10&amp;quot;~25 pix so boxes = 25 pix &amp;amp;times; 25 pix)&lt;br /&gt;
 3. Take the mean value of the standard deviation inside boxes and it's standard deviation&lt;br /&gt;
 4. Calculate SBmin and SBmax as: &lt;br /&gt;
    SBmax =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;-stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
    SBmin =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;+stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
 where &amp;lt;&amp;amp;sigma;&amp;gt; is the average standard deviation inside boxes and stdev(&amp;lt;&amp;amp;sigma;&amp;gt;) its standard deviation.&lt;br /&gt;
 5. Finally, 1 sigma surface brightness limit (SBlim) is given as:&lt;br /&gt;
    SBlim = (SBmin+SBmax)/2 +/- (SBmax-SBmin)/2&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=98</id>
		<title>CCD data reduction</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=98"/>
		<updated>2023-11-22T13:28:27Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* BPM &amp;amp; object mask creation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic data reduction using IRAF ==&lt;br /&gt;
&lt;br /&gt;
Below is a bash script that creates lists of all images: biases, flats, darks and targets.&lt;br /&gt;
Special case of dark frames of 600sec that Milankovic generates is used&lt;br /&gt;
Last lines create ascii files with median values in flat frames that will be used&lt;br /&gt;
for their normalization&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
rm *list&lt;br /&gt;
for frame in $(ls *fit); do&lt;br /&gt;
	filterType=$(gethead filter $frame)&lt;br /&gt;
	imageType=$(gethead imagetyp $frame)&lt;br /&gt;
	outFileName=$(echo $imageType | tr '[:upper:]' '[:lower:]')&lt;br /&gt;
	# test if DARK&lt;br /&gt;
	if [ ${imageType} = &amp;quot;DARK&amp;quot; ]; then&lt;br /&gt;
 		exptime=$(gethead exptime $frame | cut -d. -f1) &lt;br /&gt;
 		ls $frame &amp;gt;&amp;gt; ${outFileName}${exptime}&amp;quot;s&amp;quot;.list &lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${exptime}&amp;quot;s&amp;quot;.list&lt;br /&gt;
	else ls $frame &amp;gt;&amp;gt; ${outFileName}${filterType}.list&lt;br /&gt;
	fi&lt;br /&gt;
	# test if LIGHT and create additional lists&lt;br /&gt;
	if [ ${imageType} = &amp;quot;LIGHT&amp;quot; ]; then&lt;br /&gt;
	 	exptime=$(gethead exptime $frame | cut -d. -f1)&lt;br /&gt;
		echo $exptime &amp;gt;&amp;gt; exptime${filterType}.list&lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bdf&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bdf&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	 else if [ ${imageType} = &amp;quot;FLAT&amp;quot; ]; then&lt;br /&gt;
                echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
                echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;nbd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;nbd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	      fi&lt;br /&gt;
	 fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
# Create dark current corresponding to each light frame using exposure time&lt;br /&gt;
for exptime in $(ls exptime*.list); do &lt;br /&gt;
	filter=$(echo $exptime | sed -e s/exptime//g -e s/\.list//g);&lt;br /&gt;
	awk -v filter=${filter} '{print &amp;quot;dc&amp;quot;NR&amp;quot;_&amp;quot;filter&amp;quot;.fits&amp;quot;}' exptime${filter}.list  &amp;gt; dc${filter}.list&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce.cl ]; then rm reduce.cl; fi&lt;br /&gt;
echo &amp;quot;imdelete master_bias,dc_600s,dc_5s,dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bias.list master_bias comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark600s.list - master_bias @bdark600s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark5s.list - master_bias @bdark5s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark5s.list dc_5s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark600s.list dc_600s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl &lt;br /&gt;
echo &amp;quot;imarith dc_600s / 600 dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
&lt;br /&gt;
for flats in $(ls flat*list); do&lt;br /&gt;
        filterType=$(echo $flats | sed s/flat//g | cut -d. -f1)&lt;br /&gt;
        #echo $filterType&lt;br /&gt;
	echo &amp;quot;imarith @flat${filterType}.list - master_bias @bflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imarith @bflat${filterType}.list - dc_5s @bdflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imstat @bdflat${filterType}.list fields=\&amp;quot;image,midpt\&amp;quot; format- &amp;gt; norm${filterType}.txt&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  BPM &amp;amp; object mask creation ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cat bpmask.cl&lt;br /&gt;
imstat dc_600s field=&amp;quot;image,mean,stddev&amp;quot; for- &amp;gt; hot.txt&lt;br /&gt;
imstat master_flat_FILTER fields=&amp;quot;image,mean&amp;quot; for- &amp;gt; cold.txt&lt;br /&gt;
cl &amp;lt; bpmask.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;gt; b) ? 1 : 0)\&amp;quot; hot&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;($2+3.*$3)*0.75}' hot.txt &amp;gt; hot.cl&lt;br /&gt;
# awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;lt; b) ? 1 : 0)\&amp;quot; cold&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;$2*0.9}' cold.txt &amp;gt; cold.cl&lt;br /&gt;
cl &amp;lt; hot.cl&lt;br /&gt;
cl &amp;lt; cold.cl&lt;br /&gt;
# cat bpm.cl&lt;br /&gt;
imexpr &amp;quot;max(a,b)&amp;quot; bpmFILTER.pl a=hotFILTER.pl b=coldFILTER.pl&lt;br /&gt;
hedit @bdfFILTER.list BPM bpmFILTER.pl add+ ver- &lt;br /&gt;
# sed 's/FILTER/'${filter}'/g'  bpm.cl &amp;gt; dobpm.cl&lt;br /&gt;
cl &amp;lt; dobpm.cl&lt;br /&gt;
  &lt;br /&gt;
# Object masks creation&lt;br /&gt;
nproto&lt;br /&gt;
objmask @bdfFILTER.list @objbdfFILTER.list masks=&amp;quot;!BPM&amp;quot; hsig=2 lsig=2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Astrometry ==&lt;br /&gt;
 # cat astrometry.sh&lt;br /&gt;
 gethead OBJCTRA @bdfFILTER.list &amp;gt; name_ra.txt &lt;br /&gt;
 gethead OBJCTDEC @bdfFILTER.list | awk '{print $2,$3,$4}' &amp;gt; dec.txt&lt;br /&gt;
 paste -d&amp;quot; &amp;quot; name_ra.txt dec.txt | awk '{print $1,($2+$3/60+$4/3600)*15,$5+$6/60+$7/3600}' &amp;gt; astrometryFILTER.txt&lt;br /&gt;
 # sed s/FILTER/${filter}/g astrometry.sh  &amp;gt; astrometry${filter}.sh&lt;br /&gt;
 &lt;br /&gt;
 sh astrometry${filter}.sh&lt;br /&gt;
&lt;br /&gt;
  # This could be used:&lt;br /&gt;
  # cat komanda.sh&lt;br /&gt;
  solve-field img --ra imagera --dec imagedec --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center --wcs img.wcs &lt;br /&gt;
  ### The next command creates new files instead of just wcs binaries that can later be added to the header. It's a stand-alone command. And should be ignored.&lt;br /&gt;
  ### solve-field img --ra imagera --dec imagedec --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcsimg.fit  \ &lt;br /&gt;
  ###  -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy &lt;br /&gt;
  #while read line; do img=$(echo $line | awk '{print $1}'); imagera=$(echo $line | awk '{print $2}'); imagedec=$(echo $line | awk '{print $3}'); sed -e 's/img/'$img'/g' \ &lt;br /&gt;
 -e 's/imagera/'${imagera}'/g' -e 's/imagedec/'${imagedec}'/g' komanda.sh; done &amp;lt; astrometry${filter}.txt &amp;gt; doAstrometry.sh &lt;br /&gt;
 # Or this:&lt;br /&gt;
  awk '{print &amp;quot;solve-field &amp;quot;$1&amp;quot; --ra &amp;quot;$2&amp;quot; --dec &amp;quot;$3&amp;quot; --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcs&amp;quot;$1&amp;quot; \ &lt;br /&gt;
  -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy --wcs bla.wcs&amp;quot;}' astrometry${filter}.txt &amp;gt; doAstrometry.sh&lt;br /&gt;
&lt;br /&gt;
 # /bin/bash doAstrometry.sh&lt;br /&gt;
  #ls *wcs &amp;gt; wcs${filter}.list&lt;br /&gt;
  # echo &amp;quot;wcscopy @bdf${filter}.list @wcs${filter}.list ver-&amp;quot; &amp;gt; dowcs.cl&lt;br /&gt;
 cl &amp;lt; dowcs.cl&lt;br /&gt;
&lt;br /&gt;
== Supersky flat ==&lt;br /&gt;
 # Creation of super sky flat, normalization to each individual image median background and final stacking&lt;br /&gt;
 # cat stat.cl&lt;br /&gt;
 real mini&lt;br /&gt;
 real sky&lt;br /&gt;
 imstat(&amp;quot;img&amp;quot;,fields=&amp;quot;min&amp;quot;,lower=INDEF,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, mini)&lt;br /&gt;
 imcalc(input=&amp;quot;img,msk&amp;quot;,output=&amp;quot;skyimage&amp;quot;,equals=&amp;quot;if(im2==0.) then im1 else &amp;quot;//mini-0.001,ver-)&lt;br /&gt;
 imstat(&amp;quot;skyimage&amp;quot;,fields=&amp;quot;midpt&amp;quot;,lower=mini-0.001,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, sky)&lt;br /&gt;
 print(&amp;quot;img&amp;quot;,&amp;quot; &amp;quot;,sky)&lt;br /&gt;
 imarith(&amp;quot;img&amp;quot;,&amp;quot;/&amp;quot;,sky,&amp;quot;norm&amp;quot;)&lt;br /&gt;
 imdelete(&amp;quot;skyimage&amp;quot;,yes)&lt;br /&gt;
 # while read line; do img=$(echo $line | awk '{print $1}'); msk=&amp;quot;obj&amp;quot;${img%.*}.pl; rsky=&amp;quot;norm&amp;quot;${img}; cat stat.cl | sed -e 's/img/'${img}'/g' \&lt;br /&gt;
 -e 's/msk/'${msk}'/g'  -e 's/norm/'${rsky}'/g'; done &amp;lt; bdf${filter}.list &amp;gt;  bla.cl&lt;br /&gt;
 cl &amp;lt; bla.cl &amp;gt; med_values.txt&lt;br /&gt;
 # ls normbdf*fit &amp;gt; norm.list&lt;br /&gt;
 imcomb @norm.list norm.fits comb=med masktype=&amp;quot;!OBJMASK&amp;quot; maskval=0&lt;br /&gt;
 # awk '{print &amp;quot;imarith norm.fits * &amp;quot;$2,&amp;quot; n&amp;quot;$1}' med_values.txt &amp;gt; donorm.cl&lt;br /&gt;
 cl &amp;lt; donorm.cl&lt;br /&gt;
 # awk '{print &amp;quot;imarith&amp;quot;,$1,&amp;quot;-&amp;quot;,&amp;quot;n&amp;quot;$1,&amp;quot;s&amp;quot;$1}' med_values.txt &amp;gt; do.cl&lt;br /&gt;
 cl &amp;lt; do.cl&lt;br /&gt;
    &lt;br /&gt;
 imcomb s@bdfFILTER.list final.fits comb=med offset=&amp;quot;wcs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Surface brightness limit ==&lt;br /&gt;
&lt;br /&gt;
 1. Calibrate the image taking non-saturated stars and not too faint stars: intercept and slope (TOPCAT with SDSS DR12 from Vizier)&lt;br /&gt;
 2. Calculate statistics inside at least 20 (empty, i.e. without objects) boxes of the size of 10&amp;quot; (for example if 1pix=0.396&amp;quot; than 10&amp;quot;~25 pix so boxes = 25 pix &amp;amp;times; 25 pix)&lt;br /&gt;
 3. Take the mean value of the standard deviation inside boxes and it's standard deviation&lt;br /&gt;
 4. Calculate SBmin and SBmax as: &lt;br /&gt;
    SBmax =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;-stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
    SBmin =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;+stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
 where &amp;lt;&amp;amp;sigma;&amp;gt; is the average standard deviation inside boxes and stdev(&amp;lt;&amp;amp;sigma;&amp;gt;) its standard deviation.&lt;br /&gt;
 5. Finally, 1 sigma surface brightness limit (SBlim) is given as:&lt;br /&gt;
    SBlim = (SBmin+SBmax)/2 +/- (SBmax-SBmin)/2&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=97</id>
		<title>CCD data reduction</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=97"/>
		<updated>2023-11-22T13:27:27Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* Basic data reduction using IRAF */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic data reduction using IRAF ==&lt;br /&gt;
&lt;br /&gt;
Below is a bash script that creates lists of all images: biases, flats, darks and targets.&lt;br /&gt;
Special case of dark frames of 600sec that Milankovic generates is used&lt;br /&gt;
Last lines create ascii files with median values in flat frames that will be used&lt;br /&gt;
for their normalization&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
rm *list&lt;br /&gt;
for frame in $(ls *fit); do&lt;br /&gt;
	filterType=$(gethead filter $frame)&lt;br /&gt;
	imageType=$(gethead imagetyp $frame)&lt;br /&gt;
	outFileName=$(echo $imageType | tr '[:upper:]' '[:lower:]')&lt;br /&gt;
	# test if DARK&lt;br /&gt;
	if [ ${imageType} = &amp;quot;DARK&amp;quot; ]; then&lt;br /&gt;
 		exptime=$(gethead exptime $frame | cut -d. -f1) &lt;br /&gt;
 		ls $frame &amp;gt;&amp;gt; ${outFileName}${exptime}&amp;quot;s&amp;quot;.list &lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${exptime}&amp;quot;s&amp;quot;.list&lt;br /&gt;
	else ls $frame &amp;gt;&amp;gt; ${outFileName}${filterType}.list&lt;br /&gt;
	fi&lt;br /&gt;
	# test if LIGHT and create additional lists&lt;br /&gt;
	if [ ${imageType} = &amp;quot;LIGHT&amp;quot; ]; then&lt;br /&gt;
	 	exptime=$(gethead exptime $frame | cut -d. -f1)&lt;br /&gt;
		echo $exptime &amp;gt;&amp;gt; exptime${filterType}.list&lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bdf&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bdf&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	 else if [ ${imageType} = &amp;quot;FLAT&amp;quot; ]; then&lt;br /&gt;
                echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
                echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;nbd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;nbd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	      fi&lt;br /&gt;
	 fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
# Create dark current corresponding to each light frame using exposure time&lt;br /&gt;
for exptime in $(ls exptime*.list); do &lt;br /&gt;
	filter=$(echo $exptime | sed -e s/exptime//g -e s/\.list//g);&lt;br /&gt;
	awk -v filter=${filter} '{print &amp;quot;dc&amp;quot;NR&amp;quot;_&amp;quot;filter&amp;quot;.fits&amp;quot;}' exptime${filter}.list  &amp;gt; dc${filter}.list&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce.cl ]; then rm reduce.cl; fi&lt;br /&gt;
echo &amp;quot;imdelete master_bias,dc_600s,dc_5s,dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bias.list master_bias comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark600s.list - master_bias @bdark600s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark5s.list - master_bias @bdark5s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark5s.list dc_5s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark600s.list dc_600s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl &lt;br /&gt;
echo &amp;quot;imarith dc_600s / 600 dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
&lt;br /&gt;
for flats in $(ls flat*list); do&lt;br /&gt;
        filterType=$(echo $flats | sed s/flat//g | cut -d. -f1)&lt;br /&gt;
        #echo $filterType&lt;br /&gt;
	echo &amp;quot;imarith @flat${filterType}.list - master_bias @bflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imarith @bflat${filterType}.list - dc_5s @bdflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imstat @bdflat${filterType}.list fields=\&amp;quot;image,midpt\&amp;quot; format- &amp;gt; norm${filterType}.txt&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  BPM &amp;amp; object mask creation ==&lt;br /&gt;
  # cat bpmask.cl&lt;br /&gt;
  imstat dc_600s field=&amp;quot;image,mean,stddev&amp;quot; for- &amp;gt; hot.txt&lt;br /&gt;
  imstat master_flat_FILTER fields=&amp;quot;image,mean&amp;quot; for- &amp;gt; cold.txt&lt;br /&gt;
  cl &amp;lt; bpmask.cl&lt;br /&gt;
  # awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;gt; b) ? 1 : 0)\&amp;quot; hot&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;($2+3.*$3)*0.75}' hot.txt &amp;gt; hot.cl&lt;br /&gt;
  # awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;lt; b) ? 1 : 0)\&amp;quot; cold&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;$2*0.9}' cold.txt &amp;gt; cold.cl&lt;br /&gt;
  cl &amp;lt; hot.cl&lt;br /&gt;
  cl &amp;lt; cold.cl&lt;br /&gt;
  # cat bpm.cl&lt;br /&gt;
  imexpr &amp;quot;max(a,b)&amp;quot; bpmFILTER.pl a=hotFILTER.pl b=coldFILTER.pl&lt;br /&gt;
  hedit @bdfFILTER.list BPM bpmFILTER.pl add+ ver- &lt;br /&gt;
  # sed 's/FILTER/'${filter}'/g'  bpm.cl &amp;gt; dobpm.cl&lt;br /&gt;
  cl &amp;lt; dobpm.cl&lt;br /&gt;
  &lt;br /&gt;
  # Object masks creation&lt;br /&gt;
  nproto&lt;br /&gt;
  objmask @bdfFILTER.list @objbdfFILTER.list masks=&amp;quot;!BPM&amp;quot; hsig=2 lsig=2&lt;br /&gt;
&lt;br /&gt;
== Astrometry ==&lt;br /&gt;
 # cat astrometry.sh&lt;br /&gt;
 gethead OBJCTRA @bdfFILTER.list &amp;gt; name_ra.txt &lt;br /&gt;
 gethead OBJCTDEC @bdfFILTER.list | awk '{print $2,$3,$4}' &amp;gt; dec.txt&lt;br /&gt;
 paste -d&amp;quot; &amp;quot; name_ra.txt dec.txt | awk '{print $1,($2+$3/60+$4/3600)*15,$5+$6/60+$7/3600}' &amp;gt; astrometryFILTER.txt&lt;br /&gt;
 # sed s/FILTER/${filter}/g astrometry.sh  &amp;gt; astrometry${filter}.sh&lt;br /&gt;
 &lt;br /&gt;
 sh astrometry${filter}.sh&lt;br /&gt;
&lt;br /&gt;
  # This could be used:&lt;br /&gt;
  # cat komanda.sh&lt;br /&gt;
  solve-field img --ra imagera --dec imagedec --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center --wcs img.wcs &lt;br /&gt;
  ### The next command creates new files instead of just wcs binaries that can later be added to the header. It's a stand-alone command. And should be ignored.&lt;br /&gt;
  ### solve-field img --ra imagera --dec imagedec --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcsimg.fit  \ &lt;br /&gt;
  ###  -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy &lt;br /&gt;
  #while read line; do img=$(echo $line | awk '{print $1}'); imagera=$(echo $line | awk '{print $2}'); imagedec=$(echo $line | awk '{print $3}'); sed -e 's/img/'$img'/g' \ &lt;br /&gt;
 -e 's/imagera/'${imagera}'/g' -e 's/imagedec/'${imagedec}'/g' komanda.sh; done &amp;lt; astrometry${filter}.txt &amp;gt; doAstrometry.sh &lt;br /&gt;
 # Or this:&lt;br /&gt;
  awk '{print &amp;quot;solve-field &amp;quot;$1&amp;quot; --ra &amp;quot;$2&amp;quot; --dec &amp;quot;$3&amp;quot; --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcs&amp;quot;$1&amp;quot; \ &lt;br /&gt;
  -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy --wcs bla.wcs&amp;quot;}' astrometry${filter}.txt &amp;gt; doAstrometry.sh&lt;br /&gt;
&lt;br /&gt;
 # /bin/bash doAstrometry.sh&lt;br /&gt;
  #ls *wcs &amp;gt; wcs${filter}.list&lt;br /&gt;
  # echo &amp;quot;wcscopy @bdf${filter}.list @wcs${filter}.list ver-&amp;quot; &amp;gt; dowcs.cl&lt;br /&gt;
 cl &amp;lt; dowcs.cl&lt;br /&gt;
&lt;br /&gt;
== Supersky flat ==&lt;br /&gt;
 # Creation of super sky flat, normalization to each individual image median background and final stacking&lt;br /&gt;
 # cat stat.cl&lt;br /&gt;
 real mini&lt;br /&gt;
 real sky&lt;br /&gt;
 imstat(&amp;quot;img&amp;quot;,fields=&amp;quot;min&amp;quot;,lower=INDEF,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, mini)&lt;br /&gt;
 imcalc(input=&amp;quot;img,msk&amp;quot;,output=&amp;quot;skyimage&amp;quot;,equals=&amp;quot;if(im2==0.) then im1 else &amp;quot;//mini-0.001,ver-)&lt;br /&gt;
 imstat(&amp;quot;skyimage&amp;quot;,fields=&amp;quot;midpt&amp;quot;,lower=mini-0.001,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, sky)&lt;br /&gt;
 print(&amp;quot;img&amp;quot;,&amp;quot; &amp;quot;,sky)&lt;br /&gt;
 imarith(&amp;quot;img&amp;quot;,&amp;quot;/&amp;quot;,sky,&amp;quot;norm&amp;quot;)&lt;br /&gt;
 imdelete(&amp;quot;skyimage&amp;quot;,yes)&lt;br /&gt;
 # while read line; do img=$(echo $line | awk '{print $1}'); msk=&amp;quot;obj&amp;quot;${img%.*}.pl; rsky=&amp;quot;norm&amp;quot;${img}; cat stat.cl | sed -e 's/img/'${img}'/g' \&lt;br /&gt;
 -e 's/msk/'${msk}'/g'  -e 's/norm/'${rsky}'/g'; done &amp;lt; bdf${filter}.list &amp;gt;  bla.cl&lt;br /&gt;
 cl &amp;lt; bla.cl &amp;gt; med_values.txt&lt;br /&gt;
 # ls normbdf*fit &amp;gt; norm.list&lt;br /&gt;
 imcomb @norm.list norm.fits comb=med masktype=&amp;quot;!OBJMASK&amp;quot; maskval=0&lt;br /&gt;
 # awk '{print &amp;quot;imarith norm.fits * &amp;quot;$2,&amp;quot; n&amp;quot;$1}' med_values.txt &amp;gt; donorm.cl&lt;br /&gt;
 cl &amp;lt; donorm.cl&lt;br /&gt;
 # awk '{print &amp;quot;imarith&amp;quot;,$1,&amp;quot;-&amp;quot;,&amp;quot;n&amp;quot;$1,&amp;quot;s&amp;quot;$1}' med_values.txt &amp;gt; do.cl&lt;br /&gt;
 cl &amp;lt; do.cl&lt;br /&gt;
    &lt;br /&gt;
 imcomb s@bdfFILTER.list final.fits comb=med offset=&amp;quot;wcs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Surface brightness limit ==&lt;br /&gt;
&lt;br /&gt;
 1. Calibrate the image taking non-saturated stars and not too faint stars: intercept and slope (TOPCAT with SDSS DR12 from Vizier)&lt;br /&gt;
 2. Calculate statistics inside at least 20 (empty, i.e. without objects) boxes of the size of 10&amp;quot; (for example if 1pix=0.396&amp;quot; than 10&amp;quot;~25 pix so boxes = 25 pix &amp;amp;times; 25 pix)&lt;br /&gt;
 3. Take the mean value of the standard deviation inside boxes and it's standard deviation&lt;br /&gt;
 4. Calculate SBmin and SBmax as: &lt;br /&gt;
    SBmax =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;-stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
    SBmin =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;+stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
 where &amp;lt;&amp;amp;sigma;&amp;gt; is the average standard deviation inside boxes and stdev(&amp;lt;&amp;amp;sigma;&amp;gt;) its standard deviation.&lt;br /&gt;
 5. Finally, 1 sigma surface brightness limit (SBlim) is given as:&lt;br /&gt;
    SBlim = (SBmin+SBmax)/2 +/- (SBmax-SBmin)/2&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=96</id>
		<title>CCD data reduction</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=96"/>
		<updated>2023-11-22T13:23:03Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* BPM &amp;amp; object mask creation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic data reduction using IRAF ==&lt;br /&gt;
&lt;br /&gt;
Below is a bash script that creates lists of all images: biases, flats, darks and targets.&lt;br /&gt;
Special case of dark frames of 600sec that Milankovic generates is used&lt;br /&gt;
Last lines create ascii files with median values in flat frames that will be used&lt;br /&gt;
for their normalization&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
 rm *list&lt;br /&gt;
 for frame in $(ls *fit); do&lt;br /&gt;
	 filterType=$(gethead filter $frame)&lt;br /&gt;
	 imageType=$(gethead imagetyp $frame)&lt;br /&gt;
	 outFileName=$(echo $imageType | tr '[:upper:]' '[:lower:]')&lt;br /&gt;
	 # test if DARK&lt;br /&gt;
	 if [ ${imageType} = &amp;quot;DARK&amp;quot; ]; then&lt;br /&gt;
 		 exptime=$(gethead exptime $frame | cut -d. -f1) &lt;br /&gt;
 		 ls $frame &amp;gt;&amp;gt; ${outFileName}${exptime}&amp;quot;s&amp;quot;.list &lt;br /&gt;
		 echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${exptime}&amp;quot;s&amp;quot;.list&lt;br /&gt;
	 else ls $frame &amp;gt;&amp;gt; ${outFileName}${filterType}.list&lt;br /&gt;
	 fi&lt;br /&gt;
	 # test if LIGHT and create additional lists&lt;br /&gt;
	 if [ ${imageType} = &amp;quot;LIGHT&amp;quot; ]; then&lt;br /&gt;
	 	 exptime=$(gethead exptime $frame | cut -d. -f1)&lt;br /&gt;
		 echo $exptime &amp;gt;&amp;gt; exptime${filterType}.list&lt;br /&gt;
		 echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		 echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		 echo &amp;quot;bdf&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bdf&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	 else if [ ${imageType} = &amp;quot;FLAT&amp;quot; ]; then&lt;br /&gt;
                 echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
                 echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		 echo &amp;quot;nbd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;nbd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	       fi&lt;br /&gt;
	 fi&lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
  # Create dark current corresponding to each light frame using exposure time&lt;br /&gt;
  for exptime in $(ls exptime*.list); do &lt;br /&gt;
	 filter=$(echo $exptime | sed -e s/exptime//g -e s/\.list//g);&lt;br /&gt;
	 awk -v filter=${filter} '{print &amp;quot;dc&amp;quot;NR&amp;quot;_&amp;quot;filter&amp;quot;.fits&amp;quot;}' exptime${filter}.list  &amp;gt; dc${filter}.list&lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
  if [ -e reduce.cl ]; then rm reduce.cl; fi&lt;br /&gt;
  echo &amp;quot;imdelete master_bias,dc_600s,dc_5s,dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
  echo &amp;quot;imcombine @bias.list master_bias comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
  echo &amp;quot;imarith @dark600s.list - master_bias @bdark600s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
  echo &amp;quot;imarith @dark5s.list - master_bias @bdark5s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
  echo &amp;quot;imcombine @bdark5s.list dc_5s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
  echo &amp;quot;imcombine @bdark600s.list dc_600s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl &lt;br /&gt;
  echo &amp;quot;imarith dc_600s / 600 dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
&lt;br /&gt;
  for flats in $(ls flat*list); do&lt;br /&gt;
	 filterType=$(echo $flats | sed s/flat//g | cut -d. -f1)&lt;br /&gt;
	 #echo $filterType&lt;br /&gt;
	 echo &amp;quot;imarith @flat${filterType}.list - master_bias @bflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	 echo &amp;quot;imarith @bflat${filterType}.list - dc_5s @bdflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	 echo &amp;quot;imstat @bdflat${filterType}.list fields=\&amp;quot;image,midpt\&amp;quot; format- &amp;gt; norm${filterType}.txt&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
  done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  BPM &amp;amp; object mask creation ==&lt;br /&gt;
  # cat bpmask.cl&lt;br /&gt;
  imstat dc_600s field=&amp;quot;image,mean,stddev&amp;quot; for- &amp;gt; hot.txt&lt;br /&gt;
  imstat master_flat_FILTER fields=&amp;quot;image,mean&amp;quot; for- &amp;gt; cold.txt&lt;br /&gt;
  cl &amp;lt; bpmask.cl&lt;br /&gt;
  # awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;gt; b) ? 1 : 0)\&amp;quot; hot&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;($2+3.*$3)*0.75}' hot.txt &amp;gt; hot.cl&lt;br /&gt;
  # awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;lt; b) ? 1 : 0)\&amp;quot; cold&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;$2*0.9}' cold.txt &amp;gt; cold.cl&lt;br /&gt;
  cl &amp;lt; hot.cl&lt;br /&gt;
  cl &amp;lt; cold.cl&lt;br /&gt;
  # cat bpm.cl&lt;br /&gt;
  imexpr &amp;quot;max(a,b)&amp;quot; bpmFILTER.pl a=hotFILTER.pl b=coldFILTER.pl&lt;br /&gt;
  hedit @bdfFILTER.list BPM bpmFILTER.pl add+ ver- &lt;br /&gt;
  # sed 's/FILTER/'${filter}'/g'  bpm.cl &amp;gt; dobpm.cl&lt;br /&gt;
  cl &amp;lt; dobpm.cl&lt;br /&gt;
  &lt;br /&gt;
  # Object masks creation&lt;br /&gt;
  nproto&lt;br /&gt;
  objmask @bdfFILTER.list @objbdfFILTER.list masks=&amp;quot;!BPM&amp;quot; hsig=2 lsig=2&lt;br /&gt;
&lt;br /&gt;
== Astrometry ==&lt;br /&gt;
 # cat astrometry.sh&lt;br /&gt;
 gethead OBJCTRA @bdfFILTER.list &amp;gt; name_ra.txt &lt;br /&gt;
 gethead OBJCTDEC @bdfFILTER.list | awk '{print $2,$3,$4}' &amp;gt; dec.txt&lt;br /&gt;
 paste -d&amp;quot; &amp;quot; name_ra.txt dec.txt | awk '{print $1,($2+$3/60+$4/3600)*15,$5+$6/60+$7/3600}' &amp;gt; astrometryFILTER.txt&lt;br /&gt;
 # sed s/FILTER/${filter}/g astrometry.sh  &amp;gt; astrometry${filter}.sh&lt;br /&gt;
 &lt;br /&gt;
 sh astrometry${filter}.sh&lt;br /&gt;
&lt;br /&gt;
  # This could be used:&lt;br /&gt;
  # cat komanda.sh&lt;br /&gt;
  solve-field img --ra imagera --dec imagedec --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center --wcs img.wcs &lt;br /&gt;
  ### The next command creates new files instead of just wcs binaries that can later be added to the header. It's a stand-alone command. And should be ignored.&lt;br /&gt;
  ### solve-field img --ra imagera --dec imagedec --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcsimg.fit  \ &lt;br /&gt;
  ###  -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy &lt;br /&gt;
  #while read line; do img=$(echo $line | awk '{print $1}'); imagera=$(echo $line | awk '{print $2}'); imagedec=$(echo $line | awk '{print $3}'); sed -e 's/img/'$img'/g' \ &lt;br /&gt;
 -e 's/imagera/'${imagera}'/g' -e 's/imagedec/'${imagedec}'/g' komanda.sh; done &amp;lt; astrometry${filter}.txt &amp;gt; doAstrometry.sh &lt;br /&gt;
 # Or this:&lt;br /&gt;
  awk '{print &amp;quot;solve-field &amp;quot;$1&amp;quot; --ra &amp;quot;$2&amp;quot; --dec &amp;quot;$3&amp;quot; --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcs&amp;quot;$1&amp;quot; \ &lt;br /&gt;
  -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy --wcs bla.wcs&amp;quot;}' astrometry${filter}.txt &amp;gt; doAstrometry.sh&lt;br /&gt;
&lt;br /&gt;
 # /bin/bash doAstrometry.sh&lt;br /&gt;
  #ls *wcs &amp;gt; wcs${filter}.list&lt;br /&gt;
  # echo &amp;quot;wcscopy @bdf${filter}.list @wcs${filter}.list ver-&amp;quot; &amp;gt; dowcs.cl&lt;br /&gt;
 cl &amp;lt; dowcs.cl&lt;br /&gt;
&lt;br /&gt;
== Supersky flat ==&lt;br /&gt;
 # Creation of super sky flat, normalization to each individual image median background and final stacking&lt;br /&gt;
 # cat stat.cl&lt;br /&gt;
 real mini&lt;br /&gt;
 real sky&lt;br /&gt;
 imstat(&amp;quot;img&amp;quot;,fields=&amp;quot;min&amp;quot;,lower=INDEF,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, mini)&lt;br /&gt;
 imcalc(input=&amp;quot;img,msk&amp;quot;,output=&amp;quot;skyimage&amp;quot;,equals=&amp;quot;if(im2==0.) then im1 else &amp;quot;//mini-0.001,ver-)&lt;br /&gt;
 imstat(&amp;quot;skyimage&amp;quot;,fields=&amp;quot;midpt&amp;quot;,lower=mini-0.001,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, sky)&lt;br /&gt;
 print(&amp;quot;img&amp;quot;,&amp;quot; &amp;quot;,sky)&lt;br /&gt;
 imarith(&amp;quot;img&amp;quot;,&amp;quot;/&amp;quot;,sky,&amp;quot;norm&amp;quot;)&lt;br /&gt;
 imdelete(&amp;quot;skyimage&amp;quot;,yes)&lt;br /&gt;
 # while read line; do img=$(echo $line | awk '{print $1}'); msk=&amp;quot;obj&amp;quot;${img%.*}.pl; rsky=&amp;quot;norm&amp;quot;${img}; cat stat.cl | sed -e 's/img/'${img}'/g' \&lt;br /&gt;
 -e 's/msk/'${msk}'/g'  -e 's/norm/'${rsky}'/g'; done &amp;lt; bdf${filter}.list &amp;gt;  bla.cl&lt;br /&gt;
 cl &amp;lt; bla.cl &amp;gt; med_values.txt&lt;br /&gt;
 # ls normbdf*fit &amp;gt; norm.list&lt;br /&gt;
 imcomb @norm.list norm.fits comb=med masktype=&amp;quot;!OBJMASK&amp;quot; maskval=0&lt;br /&gt;
 # awk '{print &amp;quot;imarith norm.fits * &amp;quot;$2,&amp;quot; n&amp;quot;$1}' med_values.txt &amp;gt; donorm.cl&lt;br /&gt;
 cl &amp;lt; donorm.cl&lt;br /&gt;
 # awk '{print &amp;quot;imarith&amp;quot;,$1,&amp;quot;-&amp;quot;,&amp;quot;n&amp;quot;$1,&amp;quot;s&amp;quot;$1}' med_values.txt &amp;gt; do.cl&lt;br /&gt;
 cl &amp;lt; do.cl&lt;br /&gt;
    &lt;br /&gt;
 imcomb s@bdfFILTER.list final.fits comb=med offset=&amp;quot;wcs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Surface brightness limit ==&lt;br /&gt;
&lt;br /&gt;
 1. Calibrate the image taking non-saturated stars and not too faint stars: intercept and slope (TOPCAT with SDSS DR12 from Vizier)&lt;br /&gt;
 2. Calculate statistics inside at least 20 (empty, i.e. without objects) boxes of the size of 10&amp;quot; (for example if 1pix=0.396&amp;quot; than 10&amp;quot;~25 pix so boxes = 25 pix &amp;amp;times; 25 pix)&lt;br /&gt;
 3. Take the mean value of the standard deviation inside boxes and it's standard deviation&lt;br /&gt;
 4. Calculate SBmin and SBmax as: &lt;br /&gt;
    SBmax =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;-stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
    SBmin =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;+stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
 where &amp;lt;&amp;amp;sigma;&amp;gt; is the average standard deviation inside boxes and stdev(&amp;lt;&amp;amp;sigma;&amp;gt;) its standard deviation.&lt;br /&gt;
 5. Finally, 1 sigma surface brightness limit (SBlim) is given as:&lt;br /&gt;
    SBlim = (SBmin+SBmax)/2 +/- (SBmax-SBmin)/2&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=95</id>
		<title>CCD data reduction</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=95"/>
		<updated>2023-11-22T13:22:35Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* Basic data reduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic data reduction using IRAF ==&lt;br /&gt;
&lt;br /&gt;
Below is a bash script that creates lists of all images: biases, flats, darks and targets.&lt;br /&gt;
Special case of dark frames of 600sec that Milankovic generates is used&lt;br /&gt;
Last lines create ascii files with median values in flat frames that will be used&lt;br /&gt;
for their normalization&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
 rm *list&lt;br /&gt;
 for frame in $(ls *fit); do&lt;br /&gt;
	 filterType=$(gethead filter $frame)&lt;br /&gt;
	 imageType=$(gethead imagetyp $frame)&lt;br /&gt;
	 outFileName=$(echo $imageType | tr '[:upper:]' '[:lower:]')&lt;br /&gt;
	 # test if DARK&lt;br /&gt;
	 if [ ${imageType} = &amp;quot;DARK&amp;quot; ]; then&lt;br /&gt;
 		 exptime=$(gethead exptime $frame | cut -d. -f1) &lt;br /&gt;
 		 ls $frame &amp;gt;&amp;gt; ${outFileName}${exptime}&amp;quot;s&amp;quot;.list &lt;br /&gt;
		 echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${exptime}&amp;quot;s&amp;quot;.list&lt;br /&gt;
	 else ls $frame &amp;gt;&amp;gt; ${outFileName}${filterType}.list&lt;br /&gt;
	 fi&lt;br /&gt;
	 # test if LIGHT and create additional lists&lt;br /&gt;
	 if [ ${imageType} = &amp;quot;LIGHT&amp;quot; ]; then&lt;br /&gt;
	 	 exptime=$(gethead exptime $frame | cut -d. -f1)&lt;br /&gt;
		 echo $exptime &amp;gt;&amp;gt; exptime${filterType}.list&lt;br /&gt;
		 echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		 echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		 echo &amp;quot;bdf&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bdf&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	 else if [ ${imageType} = &amp;quot;FLAT&amp;quot; ]; then&lt;br /&gt;
                 echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
                 echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		 echo &amp;quot;nbd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;nbd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	       fi&lt;br /&gt;
	 fi&lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
  # Create dark current corresponding to each light frame using exposure time&lt;br /&gt;
  for exptime in $(ls exptime*.list); do &lt;br /&gt;
	 filter=$(echo $exptime | sed -e s/exptime//g -e s/\.list//g);&lt;br /&gt;
	 awk -v filter=${filter} '{print &amp;quot;dc&amp;quot;NR&amp;quot;_&amp;quot;filter&amp;quot;.fits&amp;quot;}' exptime${filter}.list  &amp;gt; dc${filter}.list&lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
  if [ -e reduce.cl ]; then rm reduce.cl; fi&lt;br /&gt;
  echo &amp;quot;imdelete master_bias,dc_600s,dc_5s,dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
  echo &amp;quot;imcombine @bias.list master_bias comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
  echo &amp;quot;imarith @dark600s.list - master_bias @bdark600s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
  echo &amp;quot;imarith @dark5s.list - master_bias @bdark5s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
  echo &amp;quot;imcombine @bdark5s.list dc_5s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
  echo &amp;quot;imcombine @bdark600s.list dc_600s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl &lt;br /&gt;
  echo &amp;quot;imarith dc_600s / 600 dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
&lt;br /&gt;
  for flats in $(ls flat*list); do&lt;br /&gt;
	 filterType=$(echo $flats | sed s/flat//g | cut -d. -f1)&lt;br /&gt;
	 #echo $filterType&lt;br /&gt;
	 echo &amp;quot;imarith @flat${filterType}.list - master_bias @bflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	 echo &amp;quot;imarith @bflat${filterType}.list - dc_5s @bdflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	 echo &amp;quot;imstat @bdflat${filterType}.list fields=\&amp;quot;image,midpt\&amp;quot; format- &amp;gt; norm${filterType}.txt&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
  done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  BPM &amp;amp; object mask creation ==&lt;br /&gt;
  # cat bpmask.cl&lt;br /&gt;
  imstat dc_300s field=&amp;quot;image,mean,stddev&amp;quot; for- &amp;gt; hot.txt&lt;br /&gt;
  imstat master_flat_FILTER fields=&amp;quot;image,mean&amp;quot; for- &amp;gt; cold.txt&lt;br /&gt;
  cl &amp;lt; bpmask.cl&lt;br /&gt;
  # awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;gt; b) ? 1 : 0)\&amp;quot; hot&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;($2+3.*$3)*0.75}' hot.txt &amp;gt; hot.cl&lt;br /&gt;
  # awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;lt; b) ? 1 : 0)\&amp;quot; cold&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;$2*0.9}' cold.txt &amp;gt; cold.cl&lt;br /&gt;
  cl &amp;lt; hot.cl&lt;br /&gt;
  cl &amp;lt; cold.cl&lt;br /&gt;
  # cat bpm.cl&lt;br /&gt;
  imexpr &amp;quot;max(a,b)&amp;quot; bpmFILTER.pl a=hotFILTER.pl b=coldFILTER.pl&lt;br /&gt;
  hedit @bdfFILTER.list BPM bpmFILTER.pl add+ ver- &lt;br /&gt;
  # sed 's/FILTER/'${filter}'/g'  bpm.cl &amp;gt; dobpm.cl&lt;br /&gt;
  cl &amp;lt; dobpm.cl&lt;br /&gt;
  &lt;br /&gt;
  # Object masks creation&lt;br /&gt;
  nproto&lt;br /&gt;
  objmask @bdfFILTER.list @objbdfFILTER.list masks=&amp;quot;!BPM&amp;quot; hsig=2 lsig=2&lt;br /&gt;
&lt;br /&gt;
== Astrometry ==&lt;br /&gt;
 # cat astrometry.sh&lt;br /&gt;
 gethead OBJCTRA @bdfFILTER.list &amp;gt; name_ra.txt &lt;br /&gt;
 gethead OBJCTDEC @bdfFILTER.list | awk '{print $2,$3,$4}' &amp;gt; dec.txt&lt;br /&gt;
 paste -d&amp;quot; &amp;quot; name_ra.txt dec.txt | awk '{print $1,($2+$3/60+$4/3600)*15,$5+$6/60+$7/3600}' &amp;gt; astrometryFILTER.txt&lt;br /&gt;
 # sed s/FILTER/${filter}/g astrometry.sh  &amp;gt; astrometry${filter}.sh&lt;br /&gt;
 &lt;br /&gt;
 sh astrometry${filter}.sh&lt;br /&gt;
&lt;br /&gt;
  # This could be used:&lt;br /&gt;
  # cat komanda.sh&lt;br /&gt;
  solve-field img --ra imagera --dec imagedec --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center --wcs img.wcs &lt;br /&gt;
  ### The next command creates new files instead of just wcs binaries that can later be added to the header. It's a stand-alone command. And should be ignored.&lt;br /&gt;
  ### solve-field img --ra imagera --dec imagedec --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcsimg.fit  \ &lt;br /&gt;
  ###  -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy &lt;br /&gt;
  #while read line; do img=$(echo $line | awk '{print $1}'); imagera=$(echo $line | awk '{print $2}'); imagedec=$(echo $line | awk '{print $3}'); sed -e 's/img/'$img'/g' \ &lt;br /&gt;
 -e 's/imagera/'${imagera}'/g' -e 's/imagedec/'${imagedec}'/g' komanda.sh; done &amp;lt; astrometry${filter}.txt &amp;gt; doAstrometry.sh &lt;br /&gt;
 # Or this:&lt;br /&gt;
  awk '{print &amp;quot;solve-field &amp;quot;$1&amp;quot; --ra &amp;quot;$2&amp;quot; --dec &amp;quot;$3&amp;quot; --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcs&amp;quot;$1&amp;quot; \ &lt;br /&gt;
  -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy --wcs bla.wcs&amp;quot;}' astrometry${filter}.txt &amp;gt; doAstrometry.sh&lt;br /&gt;
&lt;br /&gt;
 # /bin/bash doAstrometry.sh&lt;br /&gt;
  #ls *wcs &amp;gt; wcs${filter}.list&lt;br /&gt;
  # echo &amp;quot;wcscopy @bdf${filter}.list @wcs${filter}.list ver-&amp;quot; &amp;gt; dowcs.cl&lt;br /&gt;
 cl &amp;lt; dowcs.cl&lt;br /&gt;
&lt;br /&gt;
== Supersky flat ==&lt;br /&gt;
 # Creation of super sky flat, normalization to each individual image median background and final stacking&lt;br /&gt;
 # cat stat.cl&lt;br /&gt;
 real mini&lt;br /&gt;
 real sky&lt;br /&gt;
 imstat(&amp;quot;img&amp;quot;,fields=&amp;quot;min&amp;quot;,lower=INDEF,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, mini)&lt;br /&gt;
 imcalc(input=&amp;quot;img,msk&amp;quot;,output=&amp;quot;skyimage&amp;quot;,equals=&amp;quot;if(im2==0.) then im1 else &amp;quot;//mini-0.001,ver-)&lt;br /&gt;
 imstat(&amp;quot;skyimage&amp;quot;,fields=&amp;quot;midpt&amp;quot;,lower=mini-0.001,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, sky)&lt;br /&gt;
 print(&amp;quot;img&amp;quot;,&amp;quot; &amp;quot;,sky)&lt;br /&gt;
 imarith(&amp;quot;img&amp;quot;,&amp;quot;/&amp;quot;,sky,&amp;quot;norm&amp;quot;)&lt;br /&gt;
 imdelete(&amp;quot;skyimage&amp;quot;,yes)&lt;br /&gt;
 # while read line; do img=$(echo $line | awk '{print $1}'); msk=&amp;quot;obj&amp;quot;${img%.*}.pl; rsky=&amp;quot;norm&amp;quot;${img}; cat stat.cl | sed -e 's/img/'${img}'/g' \&lt;br /&gt;
 -e 's/msk/'${msk}'/g'  -e 's/norm/'${rsky}'/g'; done &amp;lt; bdf${filter}.list &amp;gt;  bla.cl&lt;br /&gt;
 cl &amp;lt; bla.cl &amp;gt; med_values.txt&lt;br /&gt;
 # ls normbdf*fit &amp;gt; norm.list&lt;br /&gt;
 imcomb @norm.list norm.fits comb=med masktype=&amp;quot;!OBJMASK&amp;quot; maskval=0&lt;br /&gt;
 # awk '{print &amp;quot;imarith norm.fits * &amp;quot;$2,&amp;quot; n&amp;quot;$1}' med_values.txt &amp;gt; donorm.cl&lt;br /&gt;
 cl &amp;lt; donorm.cl&lt;br /&gt;
 # awk '{print &amp;quot;imarith&amp;quot;,$1,&amp;quot;-&amp;quot;,&amp;quot;n&amp;quot;$1,&amp;quot;s&amp;quot;$1}' med_values.txt &amp;gt; do.cl&lt;br /&gt;
 cl &amp;lt; do.cl&lt;br /&gt;
    &lt;br /&gt;
 imcomb s@bdfFILTER.list final.fits comb=med offset=&amp;quot;wcs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Surface brightness limit ==&lt;br /&gt;
&lt;br /&gt;
 1. Calibrate the image taking non-saturated stars and not too faint stars: intercept and slope (TOPCAT with SDSS DR12 from Vizier)&lt;br /&gt;
 2. Calculate statistics inside at least 20 (empty, i.e. without objects) boxes of the size of 10&amp;quot; (for example if 1pix=0.396&amp;quot; than 10&amp;quot;~25 pix so boxes = 25 pix &amp;amp;times; 25 pix)&lt;br /&gt;
 3. Take the mean value of the standard deviation inside boxes and it's standard deviation&lt;br /&gt;
 4. Calculate SBmin and SBmax as: &lt;br /&gt;
    SBmax =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;-stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
    SBmin =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;+stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
 where &amp;lt;&amp;amp;sigma;&amp;gt; is the average standard deviation inside boxes and stdev(&amp;lt;&amp;amp;sigma;&amp;gt;) its standard deviation.&lt;br /&gt;
 5. Finally, 1 sigma surface brightness limit (SBlim) is given as:&lt;br /&gt;
    SBlim = (SBmin+SBmax)/2 +/- (SBmax-SBmin)/2&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=94</id>
		<title>CCD data reduction</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=94"/>
		<updated>2023-11-22T13:22:09Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* Basic data reduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic data reduction ==&lt;br /&gt;
&lt;br /&gt;
Below is a bash script that creates lists of all images: biases, flats, darks and targets.&lt;br /&gt;
Special case of dark frames of 600sec that Milankovic generates is used&lt;br /&gt;
Last lines create ascii files with median values in flat frames that will be used&lt;br /&gt;
for their normalization&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
 rm *list&lt;br /&gt;
 for frame in $(ls *fit); do&lt;br /&gt;
	 filterType=$(gethead filter $frame)&lt;br /&gt;
	 imageType=$(gethead imagetyp $frame)&lt;br /&gt;
	 outFileName=$(echo $imageType | tr '[:upper:]' '[:lower:]')&lt;br /&gt;
	 # test if DARK&lt;br /&gt;
	 if [ ${imageType} = &amp;quot;DARK&amp;quot; ]; then&lt;br /&gt;
 		 exptime=$(gethead exptime $frame | cut -d. -f1) &lt;br /&gt;
 		 ls $frame &amp;gt;&amp;gt; ${outFileName}${exptime}&amp;quot;s&amp;quot;.list &lt;br /&gt;
		 echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${exptime}&amp;quot;s&amp;quot;.list&lt;br /&gt;
	 else ls $frame &amp;gt;&amp;gt; ${outFileName}${filterType}.list&lt;br /&gt;
	 fi&lt;br /&gt;
	 # test if LIGHT and create additional lists&lt;br /&gt;
	 if [ ${imageType} = &amp;quot;LIGHT&amp;quot; ]; then&lt;br /&gt;
	 	 exptime=$(gethead exptime $frame | cut -d. -f1)&lt;br /&gt;
		 echo $exptime &amp;gt;&amp;gt; exptime${filterType}.list&lt;br /&gt;
		 echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		 echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		 echo &amp;quot;bdf&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bdf&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	 else if [ ${imageType} = &amp;quot;FLAT&amp;quot; ]; then&lt;br /&gt;
                 echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
                 echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		 echo &amp;quot;nbd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;nbd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	       fi&lt;br /&gt;
	 fi&lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
  # Create dark current corresponding to each light frame using exposure time&lt;br /&gt;
  for exptime in $(ls exptime*.list); do &lt;br /&gt;
	 filter=$(echo $exptime | sed -e s/exptime//g -e s/\.list//g);&lt;br /&gt;
	 awk -v filter=${filter} '{print &amp;quot;dc&amp;quot;NR&amp;quot;_&amp;quot;filter&amp;quot;.fits&amp;quot;}' exptime${filter}.list  &amp;gt; dc${filter}.list&lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
  if [ -e reduce.cl ]; then rm reduce.cl; fi&lt;br /&gt;
  echo &amp;quot;imdelete master_bias,dc_600s,dc_5s,dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
  echo &amp;quot;imcombine @bias.list master_bias comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
  echo &amp;quot;imarith @dark600s.list - master_bias @bdark600s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
  echo &amp;quot;imarith @dark5s.list - master_bias @bdark5s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
  echo &amp;quot;imcombine @bdark5s.list dc_5s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
  echo &amp;quot;imcombine @bdark600s.list dc_600s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl &lt;br /&gt;
  echo &amp;quot;imarith dc_600s / 600 dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
&lt;br /&gt;
  for flats in $(ls flat*list); do&lt;br /&gt;
	 filterType=$(echo $flats | sed s/flat//g | cut -d. -f1)&lt;br /&gt;
	 #echo $filterType&lt;br /&gt;
	 echo &amp;quot;imarith @flat${filterType}.list - master_bias @bflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	 echo &amp;quot;imarith @bflat${filterType}.list - dc_5s @bdflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	 echo &amp;quot;imstat @bdflat${filterType}.list fields=\&amp;quot;image,midpt\&amp;quot; format- &amp;gt; norm${filterType}.txt&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
  done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  BPM &amp;amp; object mask creation ==&lt;br /&gt;
  # cat bpmask.cl&lt;br /&gt;
  imstat dc_300s field=&amp;quot;image,mean,stddev&amp;quot; for- &amp;gt; hot.txt&lt;br /&gt;
  imstat master_flat_FILTER fields=&amp;quot;image,mean&amp;quot; for- &amp;gt; cold.txt&lt;br /&gt;
  cl &amp;lt; bpmask.cl&lt;br /&gt;
  # awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;gt; b) ? 1 : 0)\&amp;quot; hot&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;($2+3.*$3)*0.75}' hot.txt &amp;gt; hot.cl&lt;br /&gt;
  # awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;lt; b) ? 1 : 0)\&amp;quot; cold&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;$2*0.9}' cold.txt &amp;gt; cold.cl&lt;br /&gt;
  cl &amp;lt; hot.cl&lt;br /&gt;
  cl &amp;lt; cold.cl&lt;br /&gt;
  # cat bpm.cl&lt;br /&gt;
  imexpr &amp;quot;max(a,b)&amp;quot; bpmFILTER.pl a=hotFILTER.pl b=coldFILTER.pl&lt;br /&gt;
  hedit @bdfFILTER.list BPM bpmFILTER.pl add+ ver- &lt;br /&gt;
  # sed 's/FILTER/'${filter}'/g'  bpm.cl &amp;gt; dobpm.cl&lt;br /&gt;
  cl &amp;lt; dobpm.cl&lt;br /&gt;
  &lt;br /&gt;
  # Object masks creation&lt;br /&gt;
  nproto&lt;br /&gt;
  objmask @bdfFILTER.list @objbdfFILTER.list masks=&amp;quot;!BPM&amp;quot; hsig=2 lsig=2&lt;br /&gt;
&lt;br /&gt;
== Astrometry ==&lt;br /&gt;
 # cat astrometry.sh&lt;br /&gt;
 gethead OBJCTRA @bdfFILTER.list &amp;gt; name_ra.txt &lt;br /&gt;
 gethead OBJCTDEC @bdfFILTER.list | awk '{print $2,$3,$4}' &amp;gt; dec.txt&lt;br /&gt;
 paste -d&amp;quot; &amp;quot; name_ra.txt dec.txt | awk '{print $1,($2+$3/60+$4/3600)*15,$5+$6/60+$7/3600}' &amp;gt; astrometryFILTER.txt&lt;br /&gt;
 # sed s/FILTER/${filter}/g astrometry.sh  &amp;gt; astrometry${filter}.sh&lt;br /&gt;
 &lt;br /&gt;
 sh astrometry${filter}.sh&lt;br /&gt;
&lt;br /&gt;
  # This could be used:&lt;br /&gt;
  # cat komanda.sh&lt;br /&gt;
  solve-field img --ra imagera --dec imagedec --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center --wcs img.wcs &lt;br /&gt;
  ### The next command creates new files instead of just wcs binaries that can later be added to the header. It's a stand-alone command. And should be ignored.&lt;br /&gt;
  ### solve-field img --ra imagera --dec imagedec --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcsimg.fit  \ &lt;br /&gt;
  ###  -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy &lt;br /&gt;
  #while read line; do img=$(echo $line | awk '{print $1}'); imagera=$(echo $line | awk '{print $2}'); imagedec=$(echo $line | awk '{print $3}'); sed -e 's/img/'$img'/g' \ &lt;br /&gt;
 -e 's/imagera/'${imagera}'/g' -e 's/imagedec/'${imagedec}'/g' komanda.sh; done &amp;lt; astrometry${filter}.txt &amp;gt; doAstrometry.sh &lt;br /&gt;
 # Or this:&lt;br /&gt;
  awk '{print &amp;quot;solve-field &amp;quot;$1&amp;quot; --ra &amp;quot;$2&amp;quot; --dec &amp;quot;$3&amp;quot; --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcs&amp;quot;$1&amp;quot; \ &lt;br /&gt;
  -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy --wcs bla.wcs&amp;quot;}' astrometry${filter}.txt &amp;gt; doAstrometry.sh&lt;br /&gt;
&lt;br /&gt;
 # /bin/bash doAstrometry.sh&lt;br /&gt;
  #ls *wcs &amp;gt; wcs${filter}.list&lt;br /&gt;
  # echo &amp;quot;wcscopy @bdf${filter}.list @wcs${filter}.list ver-&amp;quot; &amp;gt; dowcs.cl&lt;br /&gt;
 cl &amp;lt; dowcs.cl&lt;br /&gt;
&lt;br /&gt;
== Supersky flat ==&lt;br /&gt;
 # Creation of super sky flat, normalization to each individual image median background and final stacking&lt;br /&gt;
 # cat stat.cl&lt;br /&gt;
 real mini&lt;br /&gt;
 real sky&lt;br /&gt;
 imstat(&amp;quot;img&amp;quot;,fields=&amp;quot;min&amp;quot;,lower=INDEF,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, mini)&lt;br /&gt;
 imcalc(input=&amp;quot;img,msk&amp;quot;,output=&amp;quot;skyimage&amp;quot;,equals=&amp;quot;if(im2==0.) then im1 else &amp;quot;//mini-0.001,ver-)&lt;br /&gt;
 imstat(&amp;quot;skyimage&amp;quot;,fields=&amp;quot;midpt&amp;quot;,lower=mini-0.001,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, sky)&lt;br /&gt;
 print(&amp;quot;img&amp;quot;,&amp;quot; &amp;quot;,sky)&lt;br /&gt;
 imarith(&amp;quot;img&amp;quot;,&amp;quot;/&amp;quot;,sky,&amp;quot;norm&amp;quot;)&lt;br /&gt;
 imdelete(&amp;quot;skyimage&amp;quot;,yes)&lt;br /&gt;
 # while read line; do img=$(echo $line | awk '{print $1}'); msk=&amp;quot;obj&amp;quot;${img%.*}.pl; rsky=&amp;quot;norm&amp;quot;${img}; cat stat.cl | sed -e 's/img/'${img}'/g' \&lt;br /&gt;
 -e 's/msk/'${msk}'/g'  -e 's/norm/'${rsky}'/g'; done &amp;lt; bdf${filter}.list &amp;gt;  bla.cl&lt;br /&gt;
 cl &amp;lt; bla.cl &amp;gt; med_values.txt&lt;br /&gt;
 # ls normbdf*fit &amp;gt; norm.list&lt;br /&gt;
 imcomb @norm.list norm.fits comb=med masktype=&amp;quot;!OBJMASK&amp;quot; maskval=0&lt;br /&gt;
 # awk '{print &amp;quot;imarith norm.fits * &amp;quot;$2,&amp;quot; n&amp;quot;$1}' med_values.txt &amp;gt; donorm.cl&lt;br /&gt;
 cl &amp;lt; donorm.cl&lt;br /&gt;
 # awk '{print &amp;quot;imarith&amp;quot;,$1,&amp;quot;-&amp;quot;,&amp;quot;n&amp;quot;$1,&amp;quot;s&amp;quot;$1}' med_values.txt &amp;gt; do.cl&lt;br /&gt;
 cl &amp;lt; do.cl&lt;br /&gt;
    &lt;br /&gt;
 imcomb s@bdfFILTER.list final.fits comb=med offset=&amp;quot;wcs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Surface brightness limit ==&lt;br /&gt;
&lt;br /&gt;
 1. Calibrate the image taking non-saturated stars and not too faint stars: intercept and slope (TOPCAT with SDSS DR12 from Vizier)&lt;br /&gt;
 2. Calculate statistics inside at least 20 (empty, i.e. without objects) boxes of the size of 10&amp;quot; (for example if 1pix=0.396&amp;quot; than 10&amp;quot;~25 pix so boxes = 25 pix &amp;amp;times; 25 pix)&lt;br /&gt;
 3. Take the mean value of the standard deviation inside boxes and it's standard deviation&lt;br /&gt;
 4. Calculate SBmin and SBmax as: &lt;br /&gt;
    SBmax =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;-stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
    SBmin =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;+stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
 where &amp;lt;&amp;amp;sigma;&amp;gt; is the average standard deviation inside boxes and stdev(&amp;lt;&amp;amp;sigma;&amp;gt;) its standard deviation.&lt;br /&gt;
 5. Finally, 1 sigma surface brightness limit (SBlim) is given as:&lt;br /&gt;
    SBlim = (SBmin+SBmax)/2 +/- (SBmax-SBmin)/2&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=93</id>
		<title>CCD data reduction</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=93"/>
		<updated>2023-11-22T13:21:49Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* Basic data reduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic data reduction ==&lt;br /&gt;
&lt;br /&gt;
 # Below is a bash script that creates lists of all images: biases, flats, darks and targets.&lt;br /&gt;
 # Special case of dark frames of 600sec that Milankovic generates is used&lt;br /&gt;
 # Last lines create ascii files with median values in flat frames that will be used&lt;br /&gt;
 # for their normalization&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
 rm *list&lt;br /&gt;
 for frame in $(ls *fit); do&lt;br /&gt;
	 filterType=$(gethead filter $frame)&lt;br /&gt;
	 imageType=$(gethead imagetyp $frame)&lt;br /&gt;
	 outFileName=$(echo $imageType | tr '[:upper:]' '[:lower:]')&lt;br /&gt;
	 # test if DARK&lt;br /&gt;
	 if [ ${imageType} = &amp;quot;DARK&amp;quot; ]; then&lt;br /&gt;
 		 exptime=$(gethead exptime $frame | cut -d. -f1) &lt;br /&gt;
 		 ls $frame &amp;gt;&amp;gt; ${outFileName}${exptime}&amp;quot;s&amp;quot;.list &lt;br /&gt;
		 echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${exptime}&amp;quot;s&amp;quot;.list&lt;br /&gt;
	 else ls $frame &amp;gt;&amp;gt; ${outFileName}${filterType}.list&lt;br /&gt;
	 fi&lt;br /&gt;
	 # test if LIGHT and create additional lists&lt;br /&gt;
	 if [ ${imageType} = &amp;quot;LIGHT&amp;quot; ]; then&lt;br /&gt;
	 	 exptime=$(gethead exptime $frame | cut -d. -f1)&lt;br /&gt;
		 echo $exptime &amp;gt;&amp;gt; exptime${filterType}.list&lt;br /&gt;
		 echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		 echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		 echo &amp;quot;bdf&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bdf&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	 else if [ ${imageType} = &amp;quot;FLAT&amp;quot; ]; then&lt;br /&gt;
                 echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
                 echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		 echo &amp;quot;nbd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;nbd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	       fi&lt;br /&gt;
	 fi&lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
  # Create dark current corresponding to each light frame using exposure time&lt;br /&gt;
  for exptime in $(ls exptime*.list); do &lt;br /&gt;
	 filter=$(echo $exptime | sed -e s/exptime//g -e s/\.list//g);&lt;br /&gt;
	 awk -v filter=${filter} '{print &amp;quot;dc&amp;quot;NR&amp;quot;_&amp;quot;filter&amp;quot;.fits&amp;quot;}' exptime${filter}.list  &amp;gt; dc${filter}.list&lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
  if [ -e reduce.cl ]; then rm reduce.cl; fi&lt;br /&gt;
  echo &amp;quot;imdelete master_bias,dc_600s,dc_5s,dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
  echo &amp;quot;imcombine @bias.list master_bias comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
  echo &amp;quot;imarith @dark600s.list - master_bias @bdark600s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
  echo &amp;quot;imarith @dark5s.list - master_bias @bdark5s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
  echo &amp;quot;imcombine @bdark5s.list dc_5s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
  echo &amp;quot;imcombine @bdark600s.list dc_600s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl &lt;br /&gt;
  echo &amp;quot;imarith dc_600s / 600 dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
&lt;br /&gt;
  for flats in $(ls flat*list); do&lt;br /&gt;
	 filterType=$(echo $flats | sed s/flat//g | cut -d. -f1)&lt;br /&gt;
	 #echo $filterType&lt;br /&gt;
	 echo &amp;quot;imarith @flat${filterType}.list - master_bias @bflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	 echo &amp;quot;imarith @bflat${filterType}.list - dc_5s @bdflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	 echo &amp;quot;imstat @bdflat${filterType}.list fields=\&amp;quot;image,midpt\&amp;quot; format- &amp;gt; norm${filterType}.txt&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
  done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  BPM &amp;amp; object mask creation ==&lt;br /&gt;
  # cat bpmask.cl&lt;br /&gt;
  imstat dc_300s field=&amp;quot;image,mean,stddev&amp;quot; for- &amp;gt; hot.txt&lt;br /&gt;
  imstat master_flat_FILTER fields=&amp;quot;image,mean&amp;quot; for- &amp;gt; cold.txt&lt;br /&gt;
  cl &amp;lt; bpmask.cl&lt;br /&gt;
  # awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;gt; b) ? 1 : 0)\&amp;quot; hot&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;($2+3.*$3)*0.75}' hot.txt &amp;gt; hot.cl&lt;br /&gt;
  # awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;lt; b) ? 1 : 0)\&amp;quot; cold&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;$2*0.9}' cold.txt &amp;gt; cold.cl&lt;br /&gt;
  cl &amp;lt; hot.cl&lt;br /&gt;
  cl &amp;lt; cold.cl&lt;br /&gt;
  # cat bpm.cl&lt;br /&gt;
  imexpr &amp;quot;max(a,b)&amp;quot; bpmFILTER.pl a=hotFILTER.pl b=coldFILTER.pl&lt;br /&gt;
  hedit @bdfFILTER.list BPM bpmFILTER.pl add+ ver- &lt;br /&gt;
  # sed 's/FILTER/'${filter}'/g'  bpm.cl &amp;gt; dobpm.cl&lt;br /&gt;
  cl &amp;lt; dobpm.cl&lt;br /&gt;
  &lt;br /&gt;
  # Object masks creation&lt;br /&gt;
  nproto&lt;br /&gt;
  objmask @bdfFILTER.list @objbdfFILTER.list masks=&amp;quot;!BPM&amp;quot; hsig=2 lsig=2&lt;br /&gt;
&lt;br /&gt;
== Astrometry ==&lt;br /&gt;
 # cat astrometry.sh&lt;br /&gt;
 gethead OBJCTRA @bdfFILTER.list &amp;gt; name_ra.txt &lt;br /&gt;
 gethead OBJCTDEC @bdfFILTER.list | awk '{print $2,$3,$4}' &amp;gt; dec.txt&lt;br /&gt;
 paste -d&amp;quot; &amp;quot; name_ra.txt dec.txt | awk '{print $1,($2+$3/60+$4/3600)*15,$5+$6/60+$7/3600}' &amp;gt; astrometryFILTER.txt&lt;br /&gt;
 # sed s/FILTER/${filter}/g astrometry.sh  &amp;gt; astrometry${filter}.sh&lt;br /&gt;
 &lt;br /&gt;
 sh astrometry${filter}.sh&lt;br /&gt;
&lt;br /&gt;
  # This could be used:&lt;br /&gt;
  # cat komanda.sh&lt;br /&gt;
  solve-field img --ra imagera --dec imagedec --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center --wcs img.wcs &lt;br /&gt;
  ### The next command creates new files instead of just wcs binaries that can later be added to the header. It's a stand-alone command. And should be ignored.&lt;br /&gt;
  ### solve-field img --ra imagera --dec imagedec --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcsimg.fit  \ &lt;br /&gt;
  ###  -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy &lt;br /&gt;
  #while read line; do img=$(echo $line | awk '{print $1}'); imagera=$(echo $line | awk '{print $2}'); imagedec=$(echo $line | awk '{print $3}'); sed -e 's/img/'$img'/g' \ &lt;br /&gt;
 -e 's/imagera/'${imagera}'/g' -e 's/imagedec/'${imagedec}'/g' komanda.sh; done &amp;lt; astrometry${filter}.txt &amp;gt; doAstrometry.sh &lt;br /&gt;
 # Or this:&lt;br /&gt;
  awk '{print &amp;quot;solve-field &amp;quot;$1&amp;quot; --ra &amp;quot;$2&amp;quot; --dec &amp;quot;$3&amp;quot; --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcs&amp;quot;$1&amp;quot; \ &lt;br /&gt;
  -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy --wcs bla.wcs&amp;quot;}' astrometry${filter}.txt &amp;gt; doAstrometry.sh&lt;br /&gt;
&lt;br /&gt;
 # /bin/bash doAstrometry.sh&lt;br /&gt;
  #ls *wcs &amp;gt; wcs${filter}.list&lt;br /&gt;
  # echo &amp;quot;wcscopy @bdf${filter}.list @wcs${filter}.list ver-&amp;quot; &amp;gt; dowcs.cl&lt;br /&gt;
 cl &amp;lt; dowcs.cl&lt;br /&gt;
&lt;br /&gt;
== Supersky flat ==&lt;br /&gt;
 # Creation of super sky flat, normalization to each individual image median background and final stacking&lt;br /&gt;
 # cat stat.cl&lt;br /&gt;
 real mini&lt;br /&gt;
 real sky&lt;br /&gt;
 imstat(&amp;quot;img&amp;quot;,fields=&amp;quot;min&amp;quot;,lower=INDEF,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, mini)&lt;br /&gt;
 imcalc(input=&amp;quot;img,msk&amp;quot;,output=&amp;quot;skyimage&amp;quot;,equals=&amp;quot;if(im2==0.) then im1 else &amp;quot;//mini-0.001,ver-)&lt;br /&gt;
 imstat(&amp;quot;skyimage&amp;quot;,fields=&amp;quot;midpt&amp;quot;,lower=mini-0.001,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, sky)&lt;br /&gt;
 print(&amp;quot;img&amp;quot;,&amp;quot; &amp;quot;,sky)&lt;br /&gt;
 imarith(&amp;quot;img&amp;quot;,&amp;quot;/&amp;quot;,sky,&amp;quot;norm&amp;quot;)&lt;br /&gt;
 imdelete(&amp;quot;skyimage&amp;quot;,yes)&lt;br /&gt;
 # while read line; do img=$(echo $line | awk '{print $1}'); msk=&amp;quot;obj&amp;quot;${img%.*}.pl; rsky=&amp;quot;norm&amp;quot;${img}; cat stat.cl | sed -e 's/img/'${img}'/g' \&lt;br /&gt;
 -e 's/msk/'${msk}'/g'  -e 's/norm/'${rsky}'/g'; done &amp;lt; bdf${filter}.list &amp;gt;  bla.cl&lt;br /&gt;
 cl &amp;lt; bla.cl &amp;gt; med_values.txt&lt;br /&gt;
 # ls normbdf*fit &amp;gt; norm.list&lt;br /&gt;
 imcomb @norm.list norm.fits comb=med masktype=&amp;quot;!OBJMASK&amp;quot; maskval=0&lt;br /&gt;
 # awk '{print &amp;quot;imarith norm.fits * &amp;quot;$2,&amp;quot; n&amp;quot;$1}' med_values.txt &amp;gt; donorm.cl&lt;br /&gt;
 cl &amp;lt; donorm.cl&lt;br /&gt;
 # awk '{print &amp;quot;imarith&amp;quot;,$1,&amp;quot;-&amp;quot;,&amp;quot;n&amp;quot;$1,&amp;quot;s&amp;quot;$1}' med_values.txt &amp;gt; do.cl&lt;br /&gt;
 cl &amp;lt; do.cl&lt;br /&gt;
    &lt;br /&gt;
 imcomb s@bdfFILTER.list final.fits comb=med offset=&amp;quot;wcs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Surface brightness limit ==&lt;br /&gt;
&lt;br /&gt;
 1. Calibrate the image taking non-saturated stars and not too faint stars: intercept and slope (TOPCAT with SDSS DR12 from Vizier)&lt;br /&gt;
 2. Calculate statistics inside at least 20 (empty, i.e. without objects) boxes of the size of 10&amp;quot; (for example if 1pix=0.396&amp;quot; than 10&amp;quot;~25 pix so boxes = 25 pix &amp;amp;times; 25 pix)&lt;br /&gt;
 3. Take the mean value of the standard deviation inside boxes and it's standard deviation&lt;br /&gt;
 4. Calculate SBmin and SBmax as: &lt;br /&gt;
    SBmax =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;-stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
    SBmin =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;+stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
 where &amp;lt;&amp;amp;sigma;&amp;gt; is the average standard deviation inside boxes and stdev(&amp;lt;&amp;amp;sigma;&amp;gt;) its standard deviation.&lt;br /&gt;
 5. Finally, 1 sigma surface brightness limit (SBlim) is given as:&lt;br /&gt;
    SBlim = (SBmin+SBmax)/2 +/- (SBmax-SBmin)/2&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=92</id>
		<title>CCD data reduction</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=92"/>
		<updated>2023-11-22T13:17:36Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* Basic data reduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic data reduction ==&lt;br /&gt;
&lt;br /&gt;
 # Below is a bash script that creates lists of all images: biases, flats, darks and targets.&lt;br /&gt;
 # Special case of dark frames of 600sec that Milankovic generates is used&lt;br /&gt;
 # Last lines create ascii files with median values in flat frames that will be used&lt;br /&gt;
 # for their normalization&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
 rm *list&lt;br /&gt;
 for frame in $(ls *fit); do&lt;br /&gt;
	 filterType=$(gethead filter $frame)&lt;br /&gt;
	 imageType=$(gethead imagetyp $frame)&lt;br /&gt;
	 outFileName=$(echo $imageType | tr '[:upper:]' '[:lower:]')&lt;br /&gt;
	 # test if DARK&lt;br /&gt;
	 if [ ${imageType} = &amp;quot;DARK&amp;quot; ]; then&lt;br /&gt;
 		 exptime=$(gethead exptime $frame | cut -d. -f1) &lt;br /&gt;
 		 ls $frame &amp;gt;&amp;gt; ${outFileName}${exptime}&amp;quot;s&amp;quot;.list &lt;br /&gt;
		 echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${exptime}&amp;quot;s&amp;quot;.list&lt;br /&gt;
	 else ls $frame &amp;gt;&amp;gt; ${outFileName}${filterType}.list&lt;br /&gt;
	 fi&lt;br /&gt;
	 # test if LIGHT and create additional lists&lt;br /&gt;
	 if [ ${imageType} = &amp;quot;LIGHT&amp;quot; ]; then&lt;br /&gt;
	 	 exptime=$(gethead exptime $frame | cut -d. -f1)&lt;br /&gt;
		 echo $exptime &amp;gt;&amp;gt; exptime${filterType}.list&lt;br /&gt;
		 echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		 echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		 echo &amp;quot;bdf&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bdf&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	 else if [ ${imageType} = &amp;quot;FLAT&amp;quot; ]; then&lt;br /&gt;
                 echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
                 echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		 echo &amp;quot;nbd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;nbd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	       fi&lt;br /&gt;
	 fi&lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
  # Create dark current corresponding to each light frame using exposure time&lt;br /&gt;
  for exptime in $(ls exptime*.list); do &lt;br /&gt;
	 filter=$(echo $exptime | sed -e s/exptime//g -e s/\.list//g);&lt;br /&gt;
	 awk -v filter=${filter} '{print &amp;quot;dc&amp;quot;NR&amp;quot;_&amp;quot;filter&amp;quot;.fits&amp;quot;}' exptime${filter}.list  &amp;gt; dc${filter}.list&lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
  if [ -e reduce.cl ]; then rm reduce.cl; fi&lt;br /&gt;
  echo &amp;quot;imdelete master_bias,dc_600s,dc_5s,dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
  echo &amp;quot;imcombine @bias.list master_bias comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
  echo &amp;quot;imarith @dark600s.list - master_bias @bdark600s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
  echo &amp;quot;imarith @dark5s.list - master_bias @bdark5s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
  echo &amp;quot;imcombine @bdark5s.list dc_5s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
  echo &amp;quot;imcombine @bdark600s.list dc_600s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl &lt;br /&gt;
  echo &amp;quot;imarith dc_600s / 600 dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
&lt;br /&gt;
  for flats in $(ls flat*list); do&lt;br /&gt;
	 filterType=$(echo $flats | sed s/flat//g | cut -d. -f1)&lt;br /&gt;
	 #echo $filterType&lt;br /&gt;
	 echo &amp;quot;imarith @flat${filterType}.list - master_bias @bflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	 echo &amp;quot;imarith @bflat${filterType}.list - dc_5s @bdflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	 echo &amp;quot;imstat @bdflat${filterType}.list fields=\&amp;quot;image,midpt\&amp;quot; format- &amp;gt; norm${filterType}.txt&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
==  BPM &amp;amp; object mask creation ==&lt;br /&gt;
  # cat bpmask.cl&lt;br /&gt;
  imstat dc_300s field=&amp;quot;image,mean,stddev&amp;quot; for- &amp;gt; hot.txt&lt;br /&gt;
  imstat master_flat_FILTER fields=&amp;quot;image,mean&amp;quot; for- &amp;gt; cold.txt&lt;br /&gt;
  cl &amp;lt; bpmask.cl&lt;br /&gt;
  # awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;gt; b) ? 1 : 0)\&amp;quot; hot&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;($2+3.*$3)*0.75}' hot.txt &amp;gt; hot.cl&lt;br /&gt;
  # awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;lt; b) ? 1 : 0)\&amp;quot; cold&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;$2*0.9}' cold.txt &amp;gt; cold.cl&lt;br /&gt;
  cl &amp;lt; hot.cl&lt;br /&gt;
  cl &amp;lt; cold.cl&lt;br /&gt;
  # cat bpm.cl&lt;br /&gt;
  imexpr &amp;quot;max(a,b)&amp;quot; bpmFILTER.pl a=hotFILTER.pl b=coldFILTER.pl&lt;br /&gt;
  hedit @bdfFILTER.list BPM bpmFILTER.pl add+ ver- &lt;br /&gt;
  # sed 's/FILTER/'${filter}'/g'  bpm.cl &amp;gt; dobpm.cl&lt;br /&gt;
  cl &amp;lt; dobpm.cl&lt;br /&gt;
  &lt;br /&gt;
  # Object masks creation&lt;br /&gt;
  nproto&lt;br /&gt;
  objmask @bdfFILTER.list @objbdfFILTER.list masks=&amp;quot;!BPM&amp;quot; hsig=2 lsig=2&lt;br /&gt;
&lt;br /&gt;
== Astrometry ==&lt;br /&gt;
 # cat astrometry.sh&lt;br /&gt;
 gethead OBJCTRA @bdfFILTER.list &amp;gt; name_ra.txt &lt;br /&gt;
 gethead OBJCTDEC @bdfFILTER.list | awk '{print $2,$3,$4}' &amp;gt; dec.txt&lt;br /&gt;
 paste -d&amp;quot; &amp;quot; name_ra.txt dec.txt | awk '{print $1,($2+$3/60+$4/3600)*15,$5+$6/60+$7/3600}' &amp;gt; astrometryFILTER.txt&lt;br /&gt;
 # sed s/FILTER/${filter}/g astrometry.sh  &amp;gt; astrometry${filter}.sh&lt;br /&gt;
 &lt;br /&gt;
 sh astrometry${filter}.sh&lt;br /&gt;
&lt;br /&gt;
  # This could be used:&lt;br /&gt;
  # cat komanda.sh&lt;br /&gt;
  solve-field img --ra imagera --dec imagedec --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center --wcs img.wcs &lt;br /&gt;
  ### The next command creates new files instead of just wcs binaries that can later be added to the header. It's a stand-alone command. And should be ignored.&lt;br /&gt;
  ### solve-field img --ra imagera --dec imagedec --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcsimg.fit  \ &lt;br /&gt;
  ###  -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy &lt;br /&gt;
  #while read line; do img=$(echo $line | awk '{print $1}'); imagera=$(echo $line | awk '{print $2}'); imagedec=$(echo $line | awk '{print $3}'); sed -e 's/img/'$img'/g' \ &lt;br /&gt;
 -e 's/imagera/'${imagera}'/g' -e 's/imagedec/'${imagedec}'/g' komanda.sh; done &amp;lt; astrometry${filter}.txt &amp;gt; doAstrometry.sh &lt;br /&gt;
 # Or this:&lt;br /&gt;
  awk '{print &amp;quot;solve-field &amp;quot;$1&amp;quot; --ra &amp;quot;$2&amp;quot; --dec &amp;quot;$3&amp;quot; --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcs&amp;quot;$1&amp;quot; \ &lt;br /&gt;
  -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy --wcs bla.wcs&amp;quot;}' astrometry${filter}.txt &amp;gt; doAstrometry.sh&lt;br /&gt;
&lt;br /&gt;
 # /bin/bash doAstrometry.sh&lt;br /&gt;
  #ls *wcs &amp;gt; wcs${filter}.list&lt;br /&gt;
  # echo &amp;quot;wcscopy @bdf${filter}.list @wcs${filter}.list ver-&amp;quot; &amp;gt; dowcs.cl&lt;br /&gt;
 cl &amp;lt; dowcs.cl&lt;br /&gt;
&lt;br /&gt;
== Supersky flat ==&lt;br /&gt;
 # Creation of super sky flat, normalization to each individual image median background and final stacking&lt;br /&gt;
 # cat stat.cl&lt;br /&gt;
 real mini&lt;br /&gt;
 real sky&lt;br /&gt;
 imstat(&amp;quot;img&amp;quot;,fields=&amp;quot;min&amp;quot;,lower=INDEF,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, mini)&lt;br /&gt;
 imcalc(input=&amp;quot;img,msk&amp;quot;,output=&amp;quot;skyimage&amp;quot;,equals=&amp;quot;if(im2==0.) then im1 else &amp;quot;//mini-0.001,ver-)&lt;br /&gt;
 imstat(&amp;quot;skyimage&amp;quot;,fields=&amp;quot;midpt&amp;quot;,lower=mini-0.001,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, sky)&lt;br /&gt;
 print(&amp;quot;img&amp;quot;,&amp;quot; &amp;quot;,sky)&lt;br /&gt;
 imarith(&amp;quot;img&amp;quot;,&amp;quot;/&amp;quot;,sky,&amp;quot;norm&amp;quot;)&lt;br /&gt;
 imdelete(&amp;quot;skyimage&amp;quot;,yes)&lt;br /&gt;
 # while read line; do img=$(echo $line | awk '{print $1}'); msk=&amp;quot;obj&amp;quot;${img%.*}.pl; rsky=&amp;quot;norm&amp;quot;${img}; cat stat.cl | sed -e 's/img/'${img}'/g' \&lt;br /&gt;
 -e 's/msk/'${msk}'/g'  -e 's/norm/'${rsky}'/g'; done &amp;lt; bdf${filter}.list &amp;gt;  bla.cl&lt;br /&gt;
 cl &amp;lt; bla.cl &amp;gt; med_values.txt&lt;br /&gt;
 # ls normbdf*fit &amp;gt; norm.list&lt;br /&gt;
 imcomb @norm.list norm.fits comb=med masktype=&amp;quot;!OBJMASK&amp;quot; maskval=0&lt;br /&gt;
 # awk '{print &amp;quot;imarith norm.fits * &amp;quot;$2,&amp;quot; n&amp;quot;$1}' med_values.txt &amp;gt; donorm.cl&lt;br /&gt;
 cl &amp;lt; donorm.cl&lt;br /&gt;
 # awk '{print &amp;quot;imarith&amp;quot;,$1,&amp;quot;-&amp;quot;,&amp;quot;n&amp;quot;$1,&amp;quot;s&amp;quot;$1}' med_values.txt &amp;gt; do.cl&lt;br /&gt;
 cl &amp;lt; do.cl&lt;br /&gt;
    &lt;br /&gt;
 imcomb s@bdfFILTER.list final.fits comb=med offset=&amp;quot;wcs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Surface brightness limit ==&lt;br /&gt;
&lt;br /&gt;
 1. Calibrate the image taking non-saturated stars and not too faint stars: intercept and slope (TOPCAT with SDSS DR12 from Vizier)&lt;br /&gt;
 2. Calculate statistics inside at least 20 (empty, i.e. without objects) boxes of the size of 10&amp;quot; (for example if 1pix=0.396&amp;quot; than 10&amp;quot;~25 pix so boxes = 25 pix &amp;amp;times; 25 pix)&lt;br /&gt;
 3. Take the mean value of the standard deviation inside boxes and it's standard deviation&lt;br /&gt;
 4. Calculate SBmin and SBmax as: &lt;br /&gt;
    SBmax =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;-stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
    SBmin =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;+stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
 where &amp;lt;&amp;amp;sigma;&amp;gt; is the average standard deviation inside boxes and stdev(&amp;lt;&amp;amp;sigma;&amp;gt;) its standard deviation.&lt;br /&gt;
 5. Finally, 1 sigma surface brightness limit (SBlim) is given as:&lt;br /&gt;
    SBlim = (SBmin+SBmax)/2 +/- (SBmax-SBmin)/2&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=91</id>
		<title>CCD data reduction</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=91"/>
		<updated>2023-11-22T13:16:24Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* Basic data reduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic data reduction ==&lt;br /&gt;
&lt;br /&gt;
 # Below is a bash script that creates lists of all images: biases, flats, darks and targets.&lt;br /&gt;
 # Special case of dark frames of 600sec that Milankovic generates is used&lt;br /&gt;
 # Last lines create ascii files with median values in flat frames that will be used&lt;br /&gt;
 # for their normalization&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
 rm *list&lt;br /&gt;
 for frame in $(ls *fit); do&lt;br /&gt;
	filterType=$(gethead filter $frame)&lt;br /&gt;
	imageType=$(gethead imagetyp $frame)&lt;br /&gt;
	outFileName=$(echo $imageType | tr '[:upper:]' '[:lower:]')&lt;br /&gt;
	# test if DARK&lt;br /&gt;
	if [ ${imageType} = &amp;quot;DARK&amp;quot; ]; then&lt;br /&gt;
		exptime=$(gethead exptime $frame | cut -d. -f1) &lt;br /&gt;
		ls $frame &amp;gt;&amp;gt; ${outFileName}${exptime}&amp;quot;s&amp;quot;.list&lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${exptime}&amp;quot;s&amp;quot;.list&lt;br /&gt;
	else ls $frame &amp;gt;&amp;gt; ${outFileName}${filterType}.list&lt;br /&gt;
	fi&lt;br /&gt;
	# test if LIGHT and create additional lists&lt;br /&gt;
	if [ ${imageType} = &amp;quot;LIGHT&amp;quot; ]; then&lt;br /&gt;
		exptime=$(gethead exptime $frame | cut -d. -f1)&lt;br /&gt;
		echo $exptime &amp;gt;&amp;gt; exptime${filterType}.list&lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bdf&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bdf&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	else if [ ${imageType} = &amp;quot;FLAT&amp;quot; ]; then&lt;br /&gt;
                echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
                echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;nbd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;nbd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	      fi&lt;br /&gt;
	fi&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
 # Create dark current corresponding to each light frame using exposure time&lt;br /&gt;
 for exptime in $(ls exptime*.list); do &lt;br /&gt;
	filter=$(echo $exptime | sed -e s/exptime//g -e s/\.list//g);&lt;br /&gt;
	awk -v filter=${filter} '{print &amp;quot;dc&amp;quot;NR&amp;quot;_&amp;quot;filter&amp;quot;.fits&amp;quot;}' exptime${filter}.list  &amp;gt; dc${filter}.list&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
 if [ -e reduce.cl ]; then rm reduce.cl; fi&lt;br /&gt;
 echo &amp;quot;imdelete master_bias,dc_600s,dc_5s,dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
 echo &amp;quot;imcombine @bias.list master_bias comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
 echo &amp;quot;imarith @dark600s.list - master_bias @bdark600s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
 echo &amp;quot;imarith @dark5s.list - master_bias @bdark5s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
 echo &amp;quot;imcombine @bdark5s.list dc_5s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
 echo &amp;quot;imcombine @bdark600s.list dc_600s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl &lt;br /&gt;
 echo &amp;quot;imarith dc_600s / 600 dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
&lt;br /&gt;
 for flats in $(ls flat*list); do&lt;br /&gt;
	filterType=$(echo $flats | sed s/flat//g | cut -d. -f1)&lt;br /&gt;
	#echo $filterType&lt;br /&gt;
	echo &amp;quot;imarith @flat${filterType}.list - master_bias @bflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imarith @bflat${filterType}.list - dc_5s @bdflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imstat @bdflat${filterType}.list fields=\&amp;quot;image,midpt\&amp;quot; format- &amp;gt; norm${filterType}.txt&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
==  BPM &amp;amp; object mask creation ==&lt;br /&gt;
  # cat bpmask.cl&lt;br /&gt;
  imstat dc_300s field=&amp;quot;image,mean,stddev&amp;quot; for- &amp;gt; hot.txt&lt;br /&gt;
  imstat master_flat_FILTER fields=&amp;quot;image,mean&amp;quot; for- &amp;gt; cold.txt&lt;br /&gt;
  cl &amp;lt; bpmask.cl&lt;br /&gt;
  # awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;gt; b) ? 1 : 0)\&amp;quot; hot&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;($2+3.*$3)*0.75}' hot.txt &amp;gt; hot.cl&lt;br /&gt;
  # awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;lt; b) ? 1 : 0)\&amp;quot; cold&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;$2*0.9}' cold.txt &amp;gt; cold.cl&lt;br /&gt;
  cl &amp;lt; hot.cl&lt;br /&gt;
  cl &amp;lt; cold.cl&lt;br /&gt;
  # cat bpm.cl&lt;br /&gt;
  imexpr &amp;quot;max(a,b)&amp;quot; bpmFILTER.pl a=hotFILTER.pl b=coldFILTER.pl&lt;br /&gt;
  hedit @bdfFILTER.list BPM bpmFILTER.pl add+ ver- &lt;br /&gt;
  # sed 's/FILTER/'${filter}'/g'  bpm.cl &amp;gt; dobpm.cl&lt;br /&gt;
  cl &amp;lt; dobpm.cl&lt;br /&gt;
  &lt;br /&gt;
  # Object masks creation&lt;br /&gt;
  nproto&lt;br /&gt;
  objmask @bdfFILTER.list @objbdfFILTER.list masks=&amp;quot;!BPM&amp;quot; hsig=2 lsig=2&lt;br /&gt;
&lt;br /&gt;
== Astrometry ==&lt;br /&gt;
 # cat astrometry.sh&lt;br /&gt;
 gethead OBJCTRA @bdfFILTER.list &amp;gt; name_ra.txt &lt;br /&gt;
 gethead OBJCTDEC @bdfFILTER.list | awk '{print $2,$3,$4}' &amp;gt; dec.txt&lt;br /&gt;
 paste -d&amp;quot; &amp;quot; name_ra.txt dec.txt | awk '{print $1,($2+$3/60+$4/3600)*15,$5+$6/60+$7/3600}' &amp;gt; astrometryFILTER.txt&lt;br /&gt;
 # sed s/FILTER/${filter}/g astrometry.sh  &amp;gt; astrometry${filter}.sh&lt;br /&gt;
 &lt;br /&gt;
 sh astrometry${filter}.sh&lt;br /&gt;
&lt;br /&gt;
  # This could be used:&lt;br /&gt;
  # cat komanda.sh&lt;br /&gt;
  solve-field img --ra imagera --dec imagedec --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center --wcs img.wcs &lt;br /&gt;
  ### The next command creates new files instead of just wcs binaries that can later be added to the header. It's a stand-alone command. And should be ignored.&lt;br /&gt;
  ### solve-field img --ra imagera --dec imagedec --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcsimg.fit  \ &lt;br /&gt;
  ###  -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy &lt;br /&gt;
  #while read line; do img=$(echo $line | awk '{print $1}'); imagera=$(echo $line | awk '{print $2}'); imagedec=$(echo $line | awk '{print $3}'); sed -e 's/img/'$img'/g' \ &lt;br /&gt;
 -e 's/imagera/'${imagera}'/g' -e 's/imagedec/'${imagedec}'/g' komanda.sh; done &amp;lt; astrometry${filter}.txt &amp;gt; doAstrometry.sh &lt;br /&gt;
 # Or this:&lt;br /&gt;
  awk '{print &amp;quot;solve-field &amp;quot;$1&amp;quot; --ra &amp;quot;$2&amp;quot; --dec &amp;quot;$3&amp;quot; --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcs&amp;quot;$1&amp;quot; \ &lt;br /&gt;
  -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy --wcs bla.wcs&amp;quot;}' astrometry${filter}.txt &amp;gt; doAstrometry.sh&lt;br /&gt;
&lt;br /&gt;
 # /bin/bash doAstrometry.sh&lt;br /&gt;
  #ls *wcs &amp;gt; wcs${filter}.list&lt;br /&gt;
  # echo &amp;quot;wcscopy @bdf${filter}.list @wcs${filter}.list ver-&amp;quot; &amp;gt; dowcs.cl&lt;br /&gt;
 cl &amp;lt; dowcs.cl&lt;br /&gt;
&lt;br /&gt;
== Supersky flat ==&lt;br /&gt;
 # Creation of super sky flat, normalization to each individual image median background and final stacking&lt;br /&gt;
 # cat stat.cl&lt;br /&gt;
 real mini&lt;br /&gt;
 real sky&lt;br /&gt;
 imstat(&amp;quot;img&amp;quot;,fields=&amp;quot;min&amp;quot;,lower=INDEF,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, mini)&lt;br /&gt;
 imcalc(input=&amp;quot;img,msk&amp;quot;,output=&amp;quot;skyimage&amp;quot;,equals=&amp;quot;if(im2==0.) then im1 else &amp;quot;//mini-0.001,ver-)&lt;br /&gt;
 imstat(&amp;quot;skyimage&amp;quot;,fields=&amp;quot;midpt&amp;quot;,lower=mini-0.001,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, sky)&lt;br /&gt;
 print(&amp;quot;img&amp;quot;,&amp;quot; &amp;quot;,sky)&lt;br /&gt;
 imarith(&amp;quot;img&amp;quot;,&amp;quot;/&amp;quot;,sky,&amp;quot;norm&amp;quot;)&lt;br /&gt;
 imdelete(&amp;quot;skyimage&amp;quot;,yes)&lt;br /&gt;
 # while read line; do img=$(echo $line | awk '{print $1}'); msk=&amp;quot;obj&amp;quot;${img%.*}.pl; rsky=&amp;quot;norm&amp;quot;${img}; cat stat.cl | sed -e 's/img/'${img}'/g' \&lt;br /&gt;
 -e 's/msk/'${msk}'/g'  -e 's/norm/'${rsky}'/g'; done &amp;lt; bdf${filter}.list &amp;gt;  bla.cl&lt;br /&gt;
 cl &amp;lt; bla.cl &amp;gt; med_values.txt&lt;br /&gt;
 # ls normbdf*fit &amp;gt; norm.list&lt;br /&gt;
 imcomb @norm.list norm.fits comb=med masktype=&amp;quot;!OBJMASK&amp;quot; maskval=0&lt;br /&gt;
 # awk '{print &amp;quot;imarith norm.fits * &amp;quot;$2,&amp;quot; n&amp;quot;$1}' med_values.txt &amp;gt; donorm.cl&lt;br /&gt;
 cl &amp;lt; donorm.cl&lt;br /&gt;
 # awk '{print &amp;quot;imarith&amp;quot;,$1,&amp;quot;-&amp;quot;,&amp;quot;n&amp;quot;$1,&amp;quot;s&amp;quot;$1}' med_values.txt &amp;gt; do.cl&lt;br /&gt;
 cl &amp;lt; do.cl&lt;br /&gt;
    &lt;br /&gt;
 imcomb s@bdfFILTER.list final.fits comb=med offset=&amp;quot;wcs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Surface brightness limit ==&lt;br /&gt;
&lt;br /&gt;
 1. Calibrate the image taking non-saturated stars and not too faint stars: intercept and slope (TOPCAT with SDSS DR12 from Vizier)&lt;br /&gt;
 2. Calculate statistics inside at least 20 (empty, i.e. without objects) boxes of the size of 10&amp;quot; (for example if 1pix=0.396&amp;quot; than 10&amp;quot;~25 pix so boxes = 25 pix &amp;amp;times; 25 pix)&lt;br /&gt;
 3. Take the mean value of the standard deviation inside boxes and it's standard deviation&lt;br /&gt;
 4. Calculate SBmin and SBmax as: &lt;br /&gt;
    SBmax =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;-stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
    SBmin =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;+stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
 where &amp;lt;&amp;amp;sigma;&amp;gt; is the average standard deviation inside boxes and stdev(&amp;lt;&amp;amp;sigma;&amp;gt;) its standard deviation.&lt;br /&gt;
 5. Finally, 1 sigma surface brightness limit (SBlim) is given as:&lt;br /&gt;
    SBlim = (SBmin+SBmax)/2 +/- (SBmax-SBmin)/2&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=90</id>
		<title>CCD data reduction</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=90"/>
		<updated>2023-11-22T13:15:35Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* Creation of lists */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic data reduction ==&lt;br /&gt;
&lt;br /&gt;
# Below is a bash script that creates lists of all images: biases, flats, darks and targets.&lt;br /&gt;
# Special case of dark frames of 600sec that Milankovic generates is used&lt;br /&gt;
# Last lines create ascii files with median values in flat frames that will be used&lt;br /&gt;
# for their normalization&lt;br /&gt;
&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
rm *list&lt;br /&gt;
for frame in $(ls *fit); do&lt;br /&gt;
	filterType=$(gethead filter $frame)&lt;br /&gt;
	imageType=$(gethead imagetyp $frame)&lt;br /&gt;
	outFileName=$(echo $imageType | tr '[:upper:]' '[:lower:]')&lt;br /&gt;
	# test if DARK&lt;br /&gt;
	if [ ${imageType} = &amp;quot;DARK&amp;quot; ]; then&lt;br /&gt;
		exptime=$(gethead exptime $frame | cut -d. -f1) &lt;br /&gt;
		ls $frame &amp;gt;&amp;gt; ${outFileName}${exptime}&amp;quot;s&amp;quot;.list&lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${exptime}&amp;quot;s&amp;quot;.list&lt;br /&gt;
	else ls $frame &amp;gt;&amp;gt; ${outFileName}${filterType}.list&lt;br /&gt;
	fi&lt;br /&gt;
	# test if LIGHT and create additional lists&lt;br /&gt;
	if [ ${imageType} = &amp;quot;LIGHT&amp;quot; ]; then&lt;br /&gt;
		exptime=$(gethead exptime $frame | cut -d. -f1)&lt;br /&gt;
		echo $exptime &amp;gt;&amp;gt; exptime${filterType}.list&lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bdf&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bdf&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	else if [ ${imageType} = &amp;quot;FLAT&amp;quot; ]; then&lt;br /&gt;
                echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
                echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;nbd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;nbd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	      fi&lt;br /&gt;
	fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
# Create dark current corresponding to each light frame using exposure time&lt;br /&gt;
for exptime in $(ls exptime*.list); do &lt;br /&gt;
	filter=$(echo $exptime | sed -e s/exptime//g -e s/\.list//g);&lt;br /&gt;
	awk -v filter=${filter} '{print &amp;quot;dc&amp;quot;NR&amp;quot;_&amp;quot;filter&amp;quot;.fits&amp;quot;}' exptime${filter}.list  &amp;gt; dc${filter}.list&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce.cl ]; then rm reduce.cl; fi&lt;br /&gt;
echo &amp;quot;imdelete master_bias,dc_600s,dc_5s,dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bias.list master_bias comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark600s.list - master_bias @bdark600s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark5s.list - master_bias @bdark5s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark5s.list dc_5s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark600s.list dc_600s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl &lt;br /&gt;
echo &amp;quot;imarith dc_600s / 600 dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
&lt;br /&gt;
for flats in $(ls flat*list); do&lt;br /&gt;
	filterType=$(echo $flats | sed s/flat//g | cut -d. -f1)&lt;br /&gt;
	#echo $filterType&lt;br /&gt;
	echo &amp;quot;imarith @flat${filterType}.list - master_bias @bflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imarith @bflat${filterType}.list - dc_5s @bdflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imstat @bdflat${filterType}.list fields=\&amp;quot;image,midpt\&amp;quot; format- &amp;gt; norm${filterType}.txt&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
==  BPM &amp;amp; object mask creation ==&lt;br /&gt;
  # cat bpmask.cl&lt;br /&gt;
  imstat dc_300s field=&amp;quot;image,mean,stddev&amp;quot; for- &amp;gt; hot.txt&lt;br /&gt;
  imstat master_flat_FILTER fields=&amp;quot;image,mean&amp;quot; for- &amp;gt; cold.txt&lt;br /&gt;
  cl &amp;lt; bpmask.cl&lt;br /&gt;
  # awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;gt; b) ? 1 : 0)\&amp;quot; hot&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;($2+3.*$3)*0.75}' hot.txt &amp;gt; hot.cl&lt;br /&gt;
  # awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;lt; b) ? 1 : 0)\&amp;quot; cold&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;$2*0.9}' cold.txt &amp;gt; cold.cl&lt;br /&gt;
  cl &amp;lt; hot.cl&lt;br /&gt;
  cl &amp;lt; cold.cl&lt;br /&gt;
  # cat bpm.cl&lt;br /&gt;
  imexpr &amp;quot;max(a,b)&amp;quot; bpmFILTER.pl a=hotFILTER.pl b=coldFILTER.pl&lt;br /&gt;
  hedit @bdfFILTER.list BPM bpmFILTER.pl add+ ver- &lt;br /&gt;
  # sed 's/FILTER/'${filter}'/g'  bpm.cl &amp;gt; dobpm.cl&lt;br /&gt;
  cl &amp;lt; dobpm.cl&lt;br /&gt;
  &lt;br /&gt;
  # Object masks creation&lt;br /&gt;
  nproto&lt;br /&gt;
  objmask @bdfFILTER.list @objbdfFILTER.list masks=&amp;quot;!BPM&amp;quot; hsig=2 lsig=2&lt;br /&gt;
&lt;br /&gt;
== Astrometry ==&lt;br /&gt;
 # cat astrometry.sh&lt;br /&gt;
 gethead OBJCTRA @bdfFILTER.list &amp;gt; name_ra.txt &lt;br /&gt;
 gethead OBJCTDEC @bdfFILTER.list | awk '{print $2,$3,$4}' &amp;gt; dec.txt&lt;br /&gt;
 paste -d&amp;quot; &amp;quot; name_ra.txt dec.txt | awk '{print $1,($2+$3/60+$4/3600)*15,$5+$6/60+$7/3600}' &amp;gt; astrometryFILTER.txt&lt;br /&gt;
 # sed s/FILTER/${filter}/g astrometry.sh  &amp;gt; astrometry${filter}.sh&lt;br /&gt;
 &lt;br /&gt;
 sh astrometry${filter}.sh&lt;br /&gt;
&lt;br /&gt;
  # This could be used:&lt;br /&gt;
  # cat komanda.sh&lt;br /&gt;
  solve-field img --ra imagera --dec imagedec --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center --wcs img.wcs &lt;br /&gt;
  ### The next command creates new files instead of just wcs binaries that can later be added to the header. It's a stand-alone command. And should be ignored.&lt;br /&gt;
  ### solve-field img --ra imagera --dec imagedec --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcsimg.fit  \ &lt;br /&gt;
  ###  -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy &lt;br /&gt;
  #while read line; do img=$(echo $line | awk '{print $1}'); imagera=$(echo $line | awk '{print $2}'); imagedec=$(echo $line | awk '{print $3}'); sed -e 's/img/'$img'/g' \ &lt;br /&gt;
 -e 's/imagera/'${imagera}'/g' -e 's/imagedec/'${imagedec}'/g' komanda.sh; done &amp;lt; astrometry${filter}.txt &amp;gt; doAstrometry.sh &lt;br /&gt;
 # Or this:&lt;br /&gt;
  awk '{print &amp;quot;solve-field &amp;quot;$1&amp;quot; --ra &amp;quot;$2&amp;quot; --dec &amp;quot;$3&amp;quot; --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcs&amp;quot;$1&amp;quot; \ &lt;br /&gt;
  -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy --wcs bla.wcs&amp;quot;}' astrometry${filter}.txt &amp;gt; doAstrometry.sh&lt;br /&gt;
&lt;br /&gt;
 # /bin/bash doAstrometry.sh&lt;br /&gt;
  #ls *wcs &amp;gt; wcs${filter}.list&lt;br /&gt;
  # echo &amp;quot;wcscopy @bdf${filter}.list @wcs${filter}.list ver-&amp;quot; &amp;gt; dowcs.cl&lt;br /&gt;
 cl &amp;lt; dowcs.cl&lt;br /&gt;
&lt;br /&gt;
== Supersky flat ==&lt;br /&gt;
 # Creation of super sky flat, normalization to each individual image median background and final stacking&lt;br /&gt;
 # cat stat.cl&lt;br /&gt;
 real mini&lt;br /&gt;
 real sky&lt;br /&gt;
 imstat(&amp;quot;img&amp;quot;,fields=&amp;quot;min&amp;quot;,lower=INDEF,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, mini)&lt;br /&gt;
 imcalc(input=&amp;quot;img,msk&amp;quot;,output=&amp;quot;skyimage&amp;quot;,equals=&amp;quot;if(im2==0.) then im1 else &amp;quot;//mini-0.001,ver-)&lt;br /&gt;
 imstat(&amp;quot;skyimage&amp;quot;,fields=&amp;quot;midpt&amp;quot;,lower=mini-0.001,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, sky)&lt;br /&gt;
 print(&amp;quot;img&amp;quot;,&amp;quot; &amp;quot;,sky)&lt;br /&gt;
 imarith(&amp;quot;img&amp;quot;,&amp;quot;/&amp;quot;,sky,&amp;quot;norm&amp;quot;)&lt;br /&gt;
 imdelete(&amp;quot;skyimage&amp;quot;,yes)&lt;br /&gt;
 # while read line; do img=$(echo $line | awk '{print $1}'); msk=&amp;quot;obj&amp;quot;${img%.*}.pl; rsky=&amp;quot;norm&amp;quot;${img}; cat stat.cl | sed -e 's/img/'${img}'/g' \&lt;br /&gt;
 -e 's/msk/'${msk}'/g'  -e 's/norm/'${rsky}'/g'; done &amp;lt; bdf${filter}.list &amp;gt;  bla.cl&lt;br /&gt;
 cl &amp;lt; bla.cl &amp;gt; med_values.txt&lt;br /&gt;
 # ls normbdf*fit &amp;gt; norm.list&lt;br /&gt;
 imcomb @norm.list norm.fits comb=med masktype=&amp;quot;!OBJMASK&amp;quot; maskval=0&lt;br /&gt;
 # awk '{print &amp;quot;imarith norm.fits * &amp;quot;$2,&amp;quot; n&amp;quot;$1}' med_values.txt &amp;gt; donorm.cl&lt;br /&gt;
 cl &amp;lt; donorm.cl&lt;br /&gt;
 # awk '{print &amp;quot;imarith&amp;quot;,$1,&amp;quot;-&amp;quot;,&amp;quot;n&amp;quot;$1,&amp;quot;s&amp;quot;$1}' med_values.txt &amp;gt; do.cl&lt;br /&gt;
 cl &amp;lt; do.cl&lt;br /&gt;
    &lt;br /&gt;
 imcomb s@bdfFILTER.list final.fits comb=med offset=&amp;quot;wcs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Surface brightness limit ==&lt;br /&gt;
&lt;br /&gt;
 1. Calibrate the image taking non-saturated stars and not too faint stars: intercept and slope (TOPCAT with SDSS DR12 from Vizier)&lt;br /&gt;
 2. Calculate statistics inside at least 20 (empty, i.e. without objects) boxes of the size of 10&amp;quot; (for example if 1pix=0.396&amp;quot; than 10&amp;quot;~25 pix so boxes = 25 pix &amp;amp;times; 25 pix)&lt;br /&gt;
 3. Take the mean value of the standard deviation inside boxes and it's standard deviation&lt;br /&gt;
 4. Calculate SBmin and SBmax as: &lt;br /&gt;
    SBmax =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;-stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
    SBmin =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;+stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
 where &amp;lt;&amp;amp;sigma;&amp;gt; is the average standard deviation inside boxes and stdev(&amp;lt;&amp;amp;sigma;&amp;gt;) its standard deviation.&lt;br /&gt;
 5. Finally, 1 sigma surface brightness limit (SBlim) is given as:&lt;br /&gt;
    SBlim = (SBmin+SBmax)/2 +/- (SBmax-SBmin)/2&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=89</id>
		<title>CCD data reduction</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=CCD_data_reduction&amp;diff=89"/>
		<updated>2023-11-22T13:15:19Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* Basic data reduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Creation of lists ==&lt;br /&gt;
  filter=&amp;quot;L&amp;quot;&lt;br /&gt;
  ls bias*[0-9].fit &amp;gt; bias.list&lt;br /&gt;
  ls dark600s-00*fit &amp;gt; dark600s.list&lt;br /&gt;
  ls dark*5sec*fit &amp;gt; dark5s.list&lt;br /&gt;
  ls flat*${filter}.fit &amp;gt; flat${filter}.list&lt;br /&gt;
  sed s/^/b/g flat${filter}.list &amp;gt; bflat${filter}.list&lt;br /&gt;
  sed s/^/bd/g flat${filter}.list &amp;gt; bdflat${filter}.list&lt;br /&gt;
  ls ngc*${filter}.fit &amp;gt; ${filter}.list &lt;br /&gt;
  sed s/^/b/g ${filter}.list &amp;gt; b${filter}.list&lt;br /&gt;
  sed s/^/bd/g ${filter}.list &amp;gt; bd${filter}.list&lt;br /&gt;
  sed s/^/bdf/g ${filter}.list &amp;gt; bdf${filter}.list&lt;br /&gt;
  sed s/^/objbdf/g ${filter}.list | sed s/fit/pl/g &amp;gt; objbdf${filter}.list&lt;br /&gt;
&lt;br /&gt;
== Basic data reduction ==&lt;br /&gt;
&lt;br /&gt;
# Below is a bash script that creates lists of all images: biases, flats, darks and targets.&lt;br /&gt;
# Special case of dark frames of 600sec that Milankovic generates is used&lt;br /&gt;
# Last lines create ascii files with median values in flat frames that will be used&lt;br /&gt;
# for their normalization&lt;br /&gt;
&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
rm *list&lt;br /&gt;
for frame in $(ls *fit); do&lt;br /&gt;
	filterType=$(gethead filter $frame)&lt;br /&gt;
	imageType=$(gethead imagetyp $frame)&lt;br /&gt;
	outFileName=$(echo $imageType | tr '[:upper:]' '[:lower:]')&lt;br /&gt;
	# test if DARK&lt;br /&gt;
	if [ ${imageType} = &amp;quot;DARK&amp;quot; ]; then&lt;br /&gt;
		exptime=$(gethead exptime $frame | cut -d. -f1) &lt;br /&gt;
		ls $frame &amp;gt;&amp;gt; ${outFileName}${exptime}&amp;quot;s&amp;quot;.list&lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${exptime}&amp;quot;s&amp;quot;.list&lt;br /&gt;
	else ls $frame &amp;gt;&amp;gt; ${outFileName}${filterType}.list&lt;br /&gt;
	fi&lt;br /&gt;
	# test if LIGHT and create additional lists&lt;br /&gt;
	if [ ${imageType} = &amp;quot;LIGHT&amp;quot; ]; then&lt;br /&gt;
		exptime=$(gethead exptime $frame | cut -d. -f1)&lt;br /&gt;
		echo $exptime &amp;gt;&amp;gt; exptime${filterType}.list&lt;br /&gt;
		echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;bdf&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bdf&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	else if [ ${imageType} = &amp;quot;FLAT&amp;quot; ]; then&lt;br /&gt;
                echo &amp;quot;b&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;b&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
                echo &amp;quot;bd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;bd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
		echo &amp;quot;nbd&amp;quot;$frame &amp;gt;&amp;gt; &amp;quot;nbd&amp;quot;${outFileName}${filterType}.list&lt;br /&gt;
	      fi&lt;br /&gt;
	fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
# Create dark current corresponding to each light frame using exposure time&lt;br /&gt;
for exptime in $(ls exptime*.list); do &lt;br /&gt;
	filter=$(echo $exptime | sed -e s/exptime//g -e s/\.list//g);&lt;br /&gt;
	awk -v filter=${filter} '{print &amp;quot;dc&amp;quot;NR&amp;quot;_&amp;quot;filter&amp;quot;.fits&amp;quot;}' exptime${filter}.list  &amp;gt; dc${filter}.list&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
if [ -e reduce.cl ]; then rm reduce.cl; fi&lt;br /&gt;
echo &amp;quot;imdelete master_bias,dc_600s,dc_5s,dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bias.list master_bias comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark600s.list - master_bias @bdark600s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imarith @dark5s.list - master_bias @bdark5s.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark5s.list dc_5s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
echo &amp;quot;imcombine @bdark600s.list dc_600s comb=med&amp;quot; &amp;gt;&amp;gt; reduce.cl &lt;br /&gt;
echo &amp;quot;imarith dc_600s / 600 dc_1s&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
&lt;br /&gt;
for flats in $(ls flat*list); do&lt;br /&gt;
	filterType=$(echo $flats | sed s/flat//g | cut -d. -f1)&lt;br /&gt;
	#echo $filterType&lt;br /&gt;
	echo &amp;quot;imarith @flat${filterType}.list - master_bias @bflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imarith @bflat${filterType}.list - dc_5s @bdflat${filterType}.list&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
	echo &amp;quot;imstat @bdflat${filterType}.list fields=\&amp;quot;image,midpt\&amp;quot; format- &amp;gt; norm${filterType}.txt&amp;quot; &amp;gt;&amp;gt; reduce.cl&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
==  BPM &amp;amp; object mask creation ==&lt;br /&gt;
  # cat bpmask.cl&lt;br /&gt;
  imstat dc_300s field=&amp;quot;image,mean,stddev&amp;quot; for- &amp;gt; hot.txt&lt;br /&gt;
  imstat master_flat_FILTER fields=&amp;quot;image,mean&amp;quot; for- &amp;gt; cold.txt&lt;br /&gt;
  cl &amp;lt; bpmask.cl&lt;br /&gt;
  # awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;gt; b) ? 1 : 0)\&amp;quot; hot&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;($2+3.*$3)*0.75}' hot.txt &amp;gt; hot.cl&lt;br /&gt;
  # awk -v filter=&amp;quot;L&amp;quot; '{print &amp;quot;imexpr \&amp;quot;((a &amp;lt; b) ? 1 : 0)\&amp;quot; cold&amp;quot;filter&amp;quot;.pl a=&amp;quot;$1&amp;quot; b=&amp;quot;$2*0.9}' cold.txt &amp;gt; cold.cl&lt;br /&gt;
  cl &amp;lt; hot.cl&lt;br /&gt;
  cl &amp;lt; cold.cl&lt;br /&gt;
  # cat bpm.cl&lt;br /&gt;
  imexpr &amp;quot;max(a,b)&amp;quot; bpmFILTER.pl a=hotFILTER.pl b=coldFILTER.pl&lt;br /&gt;
  hedit @bdfFILTER.list BPM bpmFILTER.pl add+ ver- &lt;br /&gt;
  # sed 's/FILTER/'${filter}'/g'  bpm.cl &amp;gt; dobpm.cl&lt;br /&gt;
  cl &amp;lt; dobpm.cl&lt;br /&gt;
  &lt;br /&gt;
  # Object masks creation&lt;br /&gt;
  nproto&lt;br /&gt;
  objmask @bdfFILTER.list @objbdfFILTER.list masks=&amp;quot;!BPM&amp;quot; hsig=2 lsig=2&lt;br /&gt;
&lt;br /&gt;
== Astrometry ==&lt;br /&gt;
 # cat astrometry.sh&lt;br /&gt;
 gethead OBJCTRA @bdfFILTER.list &amp;gt; name_ra.txt &lt;br /&gt;
 gethead OBJCTDEC @bdfFILTER.list | awk '{print $2,$3,$4}' &amp;gt; dec.txt&lt;br /&gt;
 paste -d&amp;quot; &amp;quot; name_ra.txt dec.txt | awk '{print $1,($2+$3/60+$4/3600)*15,$5+$6/60+$7/3600}' &amp;gt; astrometryFILTER.txt&lt;br /&gt;
 # sed s/FILTER/${filter}/g astrometry.sh  &amp;gt; astrometry${filter}.sh&lt;br /&gt;
 &lt;br /&gt;
 sh astrometry${filter}.sh&lt;br /&gt;
&lt;br /&gt;
  # This could be used:&lt;br /&gt;
  # cat komanda.sh&lt;br /&gt;
  solve-field img --ra imagera --dec imagedec --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center --wcs img.wcs &lt;br /&gt;
  ### The next command creates new files instead of just wcs binaries that can later be added to the header. It's a stand-alone command. And should be ignored.&lt;br /&gt;
  ### solve-field img --ra imagera --dec imagedec --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcsimg.fit  \ &lt;br /&gt;
  ###  -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy &lt;br /&gt;
  #while read line; do img=$(echo $line | awk '{print $1}'); imagera=$(echo $line | awk '{print $2}'); imagedec=$(echo $line | awk '{print $3}'); sed -e 's/img/'$img'/g' \ &lt;br /&gt;
 -e 's/imagera/'${imagera}'/g' -e 's/imagedec/'${imagedec}'/g' komanda.sh; done &amp;lt; astrometry${filter}.txt &amp;gt; doAstrometry.sh &lt;br /&gt;
 # Or this:&lt;br /&gt;
  awk '{print &amp;quot;solve-field &amp;quot;$1&amp;quot; --ra &amp;quot;$2&amp;quot; --dec &amp;quot;$3&amp;quot; --radius 0.2 --scale-units arcsecperpix --scale-low 0.38 --scale-high 0.40 --crpix-center -p -N wcs&amp;quot;$1&amp;quot; \ &lt;br /&gt;
  -O -I noneI.fits -M none.fits -R none.fits -B none.fits -P none -k none -U none -y -S none --axy noneaxy --wcs bla.wcs&amp;quot;}' astrometry${filter}.txt &amp;gt; doAstrometry.sh&lt;br /&gt;
&lt;br /&gt;
 # /bin/bash doAstrometry.sh&lt;br /&gt;
  #ls *wcs &amp;gt; wcs${filter}.list&lt;br /&gt;
  # echo &amp;quot;wcscopy @bdf${filter}.list @wcs${filter}.list ver-&amp;quot; &amp;gt; dowcs.cl&lt;br /&gt;
 cl &amp;lt; dowcs.cl&lt;br /&gt;
&lt;br /&gt;
== Supersky flat ==&lt;br /&gt;
 # Creation of super sky flat, normalization to each individual image median background and final stacking&lt;br /&gt;
 # cat stat.cl&lt;br /&gt;
 real mini&lt;br /&gt;
 real sky&lt;br /&gt;
 imstat(&amp;quot;img&amp;quot;,fields=&amp;quot;min&amp;quot;,lower=INDEF,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, mini)&lt;br /&gt;
 imcalc(input=&amp;quot;img,msk&amp;quot;,output=&amp;quot;skyimage&amp;quot;,equals=&amp;quot;if(im2==0.) then im1 else &amp;quot;//mini-0.001,ver-)&lt;br /&gt;
 imstat(&amp;quot;skyimage&amp;quot;,fields=&amp;quot;midpt&amp;quot;,lower=mini-0.001,upper=INDEF,for-) | scanf(&amp;quot;%g&amp;quot;, sky)&lt;br /&gt;
 print(&amp;quot;img&amp;quot;,&amp;quot; &amp;quot;,sky)&lt;br /&gt;
 imarith(&amp;quot;img&amp;quot;,&amp;quot;/&amp;quot;,sky,&amp;quot;norm&amp;quot;)&lt;br /&gt;
 imdelete(&amp;quot;skyimage&amp;quot;,yes)&lt;br /&gt;
 # while read line; do img=$(echo $line | awk '{print $1}'); msk=&amp;quot;obj&amp;quot;${img%.*}.pl; rsky=&amp;quot;norm&amp;quot;${img}; cat stat.cl | sed -e 's/img/'${img}'/g' \&lt;br /&gt;
 -e 's/msk/'${msk}'/g'  -e 's/norm/'${rsky}'/g'; done &amp;lt; bdf${filter}.list &amp;gt;  bla.cl&lt;br /&gt;
 cl &amp;lt; bla.cl &amp;gt; med_values.txt&lt;br /&gt;
 # ls normbdf*fit &amp;gt; norm.list&lt;br /&gt;
 imcomb @norm.list norm.fits comb=med masktype=&amp;quot;!OBJMASK&amp;quot; maskval=0&lt;br /&gt;
 # awk '{print &amp;quot;imarith norm.fits * &amp;quot;$2,&amp;quot; n&amp;quot;$1}' med_values.txt &amp;gt; donorm.cl&lt;br /&gt;
 cl &amp;lt; donorm.cl&lt;br /&gt;
 # awk '{print &amp;quot;imarith&amp;quot;,$1,&amp;quot;-&amp;quot;,&amp;quot;n&amp;quot;$1,&amp;quot;s&amp;quot;$1}' med_values.txt &amp;gt; do.cl&lt;br /&gt;
 cl &amp;lt; do.cl&lt;br /&gt;
    &lt;br /&gt;
 imcomb s@bdfFILTER.list final.fits comb=med offset=&amp;quot;wcs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Surface brightness limit ==&lt;br /&gt;
&lt;br /&gt;
 1. Calibrate the image taking non-saturated stars and not too faint stars: intercept and slope (TOPCAT with SDSS DR12 from Vizier)&lt;br /&gt;
 2. Calculate statistics inside at least 20 (empty, i.e. without objects) boxes of the size of 10&amp;quot; (for example if 1pix=0.396&amp;quot; than 10&amp;quot;~25 pix so boxes = 25 pix &amp;amp;times; 25 pix)&lt;br /&gt;
 3. Take the mean value of the standard deviation inside boxes and it's standard deviation&lt;br /&gt;
 4. Calculate SBmin and SBmax as: &lt;br /&gt;
    SBmax =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;-stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
    SBmin =-2.5*log10(&amp;lt;&amp;amp;sigma;&amp;gt;+stdev(&amp;lt;&amp;amp;sigma;&amp;gt;))*slope+intercept &lt;br /&gt;
 where &amp;lt;&amp;amp;sigma;&amp;gt; is the average standard deviation inside boxes and stdev(&amp;lt;&amp;amp;sigma;&amp;gt;) its standard deviation.&lt;br /&gt;
 5. Finally, 1 sigma surface brightness limit (SBlim) is given as:&lt;br /&gt;
    SBlim = (SBmin+SBmax)/2 +/- (SBmax-SBmin)/2&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=LinuxShort&amp;diff=88</id>
		<title>LinuxShort</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=LinuxShort&amp;diff=88"/>
		<updated>2023-11-10T12:45:06Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: /* Extract particula pages from pdf file */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Usefull short commands ==&lt;br /&gt;
&lt;br /&gt;
=== '''Kill a process tree''' ===&lt;br /&gt;
&lt;br /&gt;
When some script is started from a command line in a for-loop and a process tree is made, one should find the parent process and its PID and then simply kill it:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;font color=blue&amp;gt;$ pstree username -p &amp;lt;/font&amp;gt;&lt;br /&gt;
    &amp;lt;font color=red&amp;gt;sshd(19953)---bash(19954)---bash(22238)---idl(22323)-+-{idl}(22326)&lt;br /&gt;
                                                         |-{idl}(22327)&lt;br /&gt;
                                                         |-{idl}(22328)&lt;br /&gt;
                                                         `-{idl}(22329) &amp;lt;/font&amp;gt;&lt;br /&gt;
    sshd(20096)---bash(20097)&lt;br /&gt;
    sshd(20762)---bash(20763)&lt;br /&gt;
    sshd(21087)---bash(21088)-+-grep(21309)&lt;br /&gt;
                              `-top(21308)&lt;br /&gt;
    sshd(21736)---bash(21737)&lt;br /&gt;
    sshd(21780)---bash(21781)---pstree(22331)&lt;br /&gt;
&lt;br /&gt;
Or if this tree is to long, one should ''grep'' the program (here:idl) with: $ pstree usrname -p | grep idl    &lt;br /&gt;
    &amp;lt;font color=blue&amp;gt;$ kill 19953  &amp;lt;/font&amp;gt;&lt;br /&gt;
    &amp;lt;font color=blue&amp;gt;$ pstree username -p  &amp;lt;/font&amp;gt;&lt;br /&gt;
    sshd(20096)---bash(20097)&lt;br /&gt;
    sshd(20762)---bash(20763)&lt;br /&gt;
    sshd(21087)---bash(21088)-+-grep(21309)&lt;br /&gt;
                              `-top(21308)&lt;br /&gt;
    sshd(21736)---bash(21737)&lt;br /&gt;
    sshd(21780)---bash(21781)---pstree(22332)&lt;br /&gt;
&lt;br /&gt;
===  '''Change sth inside file'''  ===&lt;br /&gt;
&lt;br /&gt;
   sed -i s/'\-9999'/'NaN'/g filename &lt;br /&gt;
&lt;br /&gt;
This will change -9999 with NaN inside a file, without making some tmp file in between.&lt;br /&gt;
&lt;br /&gt;
=== '''Print rotated picture'''  ===&lt;br /&gt;
&lt;br /&gt;
   lp -o media=a4 -o orientation-requested=4 -o fitplot figure.ps&lt;br /&gt;
&lt;br /&gt;
=== '''Print in fixed width format with awk''' ===&lt;br /&gt;
   &lt;br /&gt;
  echo $a $b $c |  awk '{for (i=1; i&amp;lt;=NF; i++) printf(&amp;quot;%-20s &amp;quot;,$i);printf (&amp;quot;\n&amp;quot;)}' &amp;gt; outfile.dat&lt;br /&gt;
&lt;br /&gt;
where strings a,b,c may be entire lines.&lt;br /&gt;
&lt;br /&gt;
=== '''Make a small size pdf out of several pdfs''' ===&lt;br /&gt;
  gs -sDEVICE=pdfwrite -q -dNOPAUSE -dBATCH -sOutputFile=MajorFile.pdf SmallFiles*.pdf &lt;br /&gt;
&lt;br /&gt;
Combined files can ba a mix of .pdf .ps and .eps files and output file can be a .ps also&lt;br /&gt;
&lt;br /&gt;
=== '''Cut a portion of a pdf file saving resolution and sharpness''' ===&lt;br /&gt;
  gs -g2700x3500 -sOUTPUTFILE=output.pdf -sDEVICE=pdfwrite -dBATCH -c &amp;quot;&amp;lt;&amp;lt; /PageOffset [-30 -120] &amp;gt;&amp;gt; setpagedevice&amp;quot; -f input.pdf&lt;br /&gt;
&lt;br /&gt;
Where [-30 -120] means - shift the content of the old image to its left corner by (x,y)=(30,120) pixels (change the origin of the image) and 2700x3500 are the dimensions of the new image. &amp;lt;font color=&amp;quot;darkred&amp;quot;&amp;gt;Be careful - input.pdf should be a single page. &amp;lt;/font&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
=== '''Make a series of single-page EPS files from various inputs''' ===&lt;br /&gt;
  gs -sDEVICE=epswrite -q -dNOPAUSE -dBATCH -dSAFER -sOutputFile=p%08d.eps 5page-first.pdf 7page-second.ps 1page-third.eps &lt;br /&gt;
&lt;br /&gt;
The resulting files will be nicely named as p00000001.eps .... p00000013.eps&lt;br /&gt;
&lt;br /&gt;
=== ''' Cut a portion of a .pdf file ''' ===&lt;br /&gt;
Make a script named boundingBox.sh:&lt;br /&gt;
  gs                          \&lt;br /&gt;
   -q                         \&lt;br /&gt;
   -dBATCH                    \&lt;br /&gt;
   -dNOPAUSE                  \&lt;br /&gt;
   -sDEVICE=bbox              \&lt;br /&gt;
   -dLastPage=1               \&lt;br /&gt;
    $1 \&lt;br /&gt;
  2&amp;gt;&amp;amp;1                        \&lt;br /&gt;
  | grep %%BoundingBox&lt;br /&gt;
&lt;br /&gt;
Call the  script from the line with file_name as input: &lt;br /&gt;
 ./boundingBox.sh file.pdf &lt;br /&gt;
&lt;br /&gt;
The result will be sth. like: %%BoundingBox: 42 510 305 746, where lower left img coords = (42,510) and upper right = (305,746). Finaly, to cut a box 305-42=263 px wide and 746-510=236 high, excluding 42 pixels from the left and 510 pixels from the bottom, make a script ''crop.sh'':&lt;br /&gt;
  gs                                                      \&lt;br /&gt;
    -o out.png                                            \&lt;br /&gt;
    -sDEVICE=pngalpha                                     \&lt;br /&gt;
    -g$2x$3                                             \&lt;br /&gt;
    -dLastPage=1                                          \&lt;br /&gt;
    -c &amp;quot;&amp;lt;&amp;lt;/Install {$4 $5 translate}&amp;gt;&amp;gt; setpagedevice&amp;quot; \&lt;br /&gt;
    -f $1 &lt;br /&gt;
&lt;br /&gt;
where $1x$2=width x height and $4 $5 are the portion excluded from the left and bootom. In this example:&lt;br /&gt;
  ./crop.sh file.pdf 263 236 -42 -510&lt;br /&gt;
&lt;br /&gt;
To make .pdf out try:&lt;br /&gt;
 gs -o out.pdf -sDEVICE=pdfwrite -c &amp;quot;[/CropBox [42 510 305 746] /PAGES pdfmark&amp;quot; -f file.eps&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== '''Extract particular pages from pdf file''' ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  #!/bin/sh&lt;br /&gt;
  #&lt;br /&gt;
  # pdfsplit [input.pdf] [first_page] [last_page] [output.pdf] &lt;br /&gt;
  #&lt;br /&gt;
  # Example: pdfsplit big_file.pdf 10 20 pages_ten_to_twenty.pdf&lt;br /&gt;
  #&lt;br /&gt;
  # written by: Westley Weimer, Wed Mar 19 17:58:09 EDT 2008&lt;br /&gt;
  #&lt;br /&gt;
  # The trick: ghostscript (gs) will do PDF splitting for you, it's just not&lt;br /&gt;
  # obvious and the required defines are not listed in the manual page. &lt;br /&gt;
&lt;br /&gt;
  if [ $# -lt 4 ] &lt;br /&gt;
  then&lt;br /&gt;
          echo &amp;quot;Usage: pdfsplit input.pdf first_page last_page output.pdf&amp;quot;&lt;br /&gt;
          exit 1&lt;br /&gt;
  fi&lt;br /&gt;
  gs -dNOPAUSE -dQUIET -dBATCH -sOutputFile=&amp;quot;$4&amp;quot; -dFirstPage=$2 -dLastPage=$3 -sDEVICE=pdfwrite &amp;quot;$1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== '''Convert eps to jpg using native gs''' ===&lt;br /&gt;
  gs -sDEVICE=jpeg -q -dJPEGQ=100 -dNOPAUSE -dBATCH -dSAFER -r100 -sOutputFile=image.jpg image.eps # ''-r100'' should be changed to ''-r50'' for denser image &lt;br /&gt;
&lt;br /&gt;
=== '''Convert (e)ps to png or gif ''' ===&lt;br /&gt;
&lt;br /&gt;
 name=&amp;quot;imgName&amp;quot;; figdir=&amp;quot;/home/..../Figures&amp;quot;; text=&amp;quot;my image&amp;quot;&lt;br /&gt;
 1. convert $name.ps -depth 8 -alpha off -density 600 &lt;br /&gt;
 2. convert $name.ps -depth 8 -alpha off -density 600 ${figdir}/${name}_large.gif &lt;br /&gt;
 3. convert $name.ps -depth 8 -alpha off -density 600 -resize 320x240 ${figdir}/${name}_large.gif&lt;br /&gt;
 4. convert $name.ps -depth 8 -alpha off -density 600 -gravity Southeast -font helvetica -pointsize 75 \ &lt;br /&gt;
 -draw &amp;quot;text 150,100 '$text'&amp;quot; ${figdir}/${name}_large.gif&lt;br /&gt;
&lt;br /&gt;
1. Resulting image will be named as .eps and will end up at the same place.&lt;br /&gt;
&lt;br /&gt;
2. Resulting image will be named imgName_large.gif and will be placed in \$figdir.&lt;br /&gt;
&lt;br /&gt;
3. Additionally, image can be resized in the same step.&lt;br /&gt;
&lt;br /&gt;
4. Put text into image&lt;br /&gt;
&lt;br /&gt;
=== '''Resize image'''  ===&lt;br /&gt;
  mogrify -trim -resize 70% image.jpg   # or ''-resize 800x600'' for fixed width&lt;br /&gt;
&lt;br /&gt;
=== Screen command ===&lt;br /&gt;
  screen -S name # name a screen&lt;br /&gt;
  screen -ls # list all screens (those named will be easily read)&lt;br /&gt;
  Ctrl+a+d # detach screen&lt;br /&gt;
  screen -r name # attach to a screen&lt;br /&gt;
  screen -S name -X quit # kill detached screen and return to a terminal&lt;br /&gt;
  ls -laR /var/run/screen/ # lists when the screens start running&lt;br /&gt;
&lt;br /&gt;
=== Several images into one ===&lt;br /&gt;
  montage img1.png img2.png img3.png img4.png img5.png img6.png -tile 2x3  -frame 2  -geometry +0+0 out.png &lt;br /&gt;
&lt;br /&gt;
=== Animation on .gif images ===&lt;br /&gt;
  convert -delay 50 img1.gif img2.gif -loop 0 anim.gif&lt;br /&gt;
&lt;br /&gt;
== Some cool stuff ==&lt;br /&gt;
&lt;br /&gt;
* Very nice themes for Ubuntu 10.04&lt;br /&gt;
&lt;br /&gt;
    sudo add-apt-repository ppa:bisigi&lt;br /&gt;
    sudo aptitude update&lt;br /&gt;
    sudo aptitude install bisigi-themes&lt;br /&gt;
&lt;br /&gt;
* Convert youtube .flv to .mp3 ([http://ubuntuforums.org/showthread.php?t=1117283 FORUM])&lt;br /&gt;
   sudo apt-get install youtube-dl&lt;br /&gt;
   sudo youtube-dl -U&lt;br /&gt;
   sudo youtube-dl -U&lt;br /&gt;
   sudo apt-get install ffmpeg libavcodec-unstripped-52&lt;br /&gt;
   sudo apt-get install ubuntu-restricted-extras &lt;br /&gt;
   # Example:&lt;br /&gt;
   youtube-dl http://www.youtube.com/watch?v=Md7IhGYKncs&lt;br /&gt;
   ffmpeg -i Md7IhGYKncs.flv -acodec libmp3lame -ab 128 indiana.mp3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Install IRAF in Ubuntu 16 with Anaconda ==&lt;br /&gt;
&lt;br /&gt;
Source: https://www.anaconda.com/download/#_unix&lt;br /&gt;
&lt;br /&gt;
First install the following libs:&lt;br /&gt;
&lt;br /&gt;
   sudo apt-get install libc6:i386 libz1:i386 libncurses5:i386 libbz2-1.0:i386 libuuid1:i386 libxcb1:i386 &lt;br /&gt;
   sudo apt-get install libxmu-dev:i386&lt;br /&gt;
&lt;br /&gt;
Then download Anaconda from https://www.continuum.io/downloads&lt;br /&gt;
&lt;br /&gt;
   cd /home/&amp;lt;user_name&amp;gt;/&lt;br /&gt;
   bash Anaconda2-4.4.0-Linux-x86_64.sh&lt;br /&gt;
   conda config --add channels http://ssb.stsci.edu/astroconda&lt;br /&gt;
   conda create -n iraf python=2.7 iraf-all pyraf-all stsci&lt;br /&gt;
   source activate iraf&lt;br /&gt;
   mkiraf&lt;br /&gt;
   &amp;lt;set to xgterm&amp;gt;&lt;br /&gt;
   cl&lt;br /&gt;
   ...&lt;br /&gt;
   source deactivate iraf&lt;br /&gt;
      &lt;br /&gt;
Pyraf also works in a standard way...&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.aob.rs/index.php?title=LinuxShort&amp;diff=87</id>
		<title>LinuxShort</title>
		<link rel="alternate" type="text/html" href="http://wiki.aob.rs/index.php?title=LinuxShort&amp;diff=87"/>
		<updated>2023-11-10T12:44:49Z</updated>

		<summary type="html">&lt;p&gt;Ana.Lalovic: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Usefull short commands ==&lt;br /&gt;
&lt;br /&gt;
=== '''Kill a process tree''' ===&lt;br /&gt;
&lt;br /&gt;
When some script is started from a command line in a for-loop and a process tree is made, one should find the parent process and its PID and then simply kill it:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;font color=blue&amp;gt;$ pstree username -p &amp;lt;/font&amp;gt;&lt;br /&gt;
    &amp;lt;font color=red&amp;gt;sshd(19953)---bash(19954)---bash(22238)---idl(22323)-+-{idl}(22326)&lt;br /&gt;
                                                         |-{idl}(22327)&lt;br /&gt;
                                                         |-{idl}(22328)&lt;br /&gt;
                                                         `-{idl}(22329) &amp;lt;/font&amp;gt;&lt;br /&gt;
    sshd(20096)---bash(20097)&lt;br /&gt;
    sshd(20762)---bash(20763)&lt;br /&gt;
    sshd(21087)---bash(21088)-+-grep(21309)&lt;br /&gt;
                              `-top(21308)&lt;br /&gt;
    sshd(21736)---bash(21737)&lt;br /&gt;
    sshd(21780)---bash(21781)---pstree(22331)&lt;br /&gt;
&lt;br /&gt;
Or if this tree is to long, one should ''grep'' the program (here:idl) with: $ pstree usrname -p | grep idl    &lt;br /&gt;
    &amp;lt;font color=blue&amp;gt;$ kill 19953  &amp;lt;/font&amp;gt;&lt;br /&gt;
    &amp;lt;font color=blue&amp;gt;$ pstree username -p  &amp;lt;/font&amp;gt;&lt;br /&gt;
    sshd(20096)---bash(20097)&lt;br /&gt;
    sshd(20762)---bash(20763)&lt;br /&gt;
    sshd(21087)---bash(21088)-+-grep(21309)&lt;br /&gt;
                              `-top(21308)&lt;br /&gt;
    sshd(21736)---bash(21737)&lt;br /&gt;
    sshd(21780)---bash(21781)---pstree(22332)&lt;br /&gt;
&lt;br /&gt;
===  '''Change sth inside file'''  ===&lt;br /&gt;
&lt;br /&gt;
   sed -i s/'\-9999'/'NaN'/g filename &lt;br /&gt;
&lt;br /&gt;
This will change -9999 with NaN inside a file, without making some tmp file in between.&lt;br /&gt;
&lt;br /&gt;
=== '''Print rotated picture'''  ===&lt;br /&gt;
&lt;br /&gt;
   lp -o media=a4 -o orientation-requested=4 -o fitplot figure.ps&lt;br /&gt;
&lt;br /&gt;
=== '''Print in fixed width format with awk''' ===&lt;br /&gt;
   &lt;br /&gt;
  echo $a $b $c |  awk '{for (i=1; i&amp;lt;=NF; i++) printf(&amp;quot;%-20s &amp;quot;,$i);printf (&amp;quot;\n&amp;quot;)}' &amp;gt; outfile.dat&lt;br /&gt;
&lt;br /&gt;
where strings a,b,c may be entire lines.&lt;br /&gt;
&lt;br /&gt;
=== '''Make a small size pdf out of several pdfs''' ===&lt;br /&gt;
  gs -sDEVICE=pdfwrite -q -dNOPAUSE -dBATCH -sOutputFile=MajorFile.pdf SmallFiles*.pdf &lt;br /&gt;
&lt;br /&gt;
Combined files can ba a mix of .pdf .ps and .eps files and output file can be a .ps also&lt;br /&gt;
&lt;br /&gt;
=== '''Cut a portion of a pdf file saving resolution and sharpness''' ===&lt;br /&gt;
  gs -g2700x3500 -sOUTPUTFILE=output.pdf -sDEVICE=pdfwrite -dBATCH -c &amp;quot;&amp;lt;&amp;lt; /PageOffset [-30 -120] &amp;gt;&amp;gt; setpagedevice&amp;quot; -f input.pdf&lt;br /&gt;
&lt;br /&gt;
Where [-30 -120] means - shift the content of the old image to its left corner by (x,y)=(30,120) pixels (change the origin of the image) and 2700x3500 are the dimensions of the new image. &amp;lt;font color=&amp;quot;darkred&amp;quot;&amp;gt;Be careful - input.pdf should be a single page. &amp;lt;/font&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
=== '''Make a series of single-page EPS files from various inputs''' ===&lt;br /&gt;
  gs -sDEVICE=epswrite -q -dNOPAUSE -dBATCH -dSAFER -sOutputFile=p%08d.eps 5page-first.pdf 7page-second.ps 1page-third.eps &lt;br /&gt;
&lt;br /&gt;
The resulting files will be nicely named as p00000001.eps .... p00000013.eps&lt;br /&gt;
&lt;br /&gt;
=== ''' Cut a portion of a .pdf file ''' ===&lt;br /&gt;
Make a script named boundingBox.sh:&lt;br /&gt;
  gs                          \&lt;br /&gt;
   -q                         \&lt;br /&gt;
   -dBATCH                    \&lt;br /&gt;
   -dNOPAUSE                  \&lt;br /&gt;
   -sDEVICE=bbox              \&lt;br /&gt;
   -dLastPage=1               \&lt;br /&gt;
    $1 \&lt;br /&gt;
  2&amp;gt;&amp;amp;1                        \&lt;br /&gt;
  | grep %%BoundingBox&lt;br /&gt;
&lt;br /&gt;
Call the  script from the line with file_name as input: &lt;br /&gt;
 ./boundingBox.sh file.pdf &lt;br /&gt;
&lt;br /&gt;
The result will be sth. like: %%BoundingBox: 42 510 305 746, where lower left img coords = (42,510) and upper right = (305,746). Finaly, to cut a box 305-42=263 px wide and 746-510=236 high, excluding 42 pixels from the left and 510 pixels from the bottom, make a script ''crop.sh'':&lt;br /&gt;
  gs                                                      \&lt;br /&gt;
    -o out.png                                            \&lt;br /&gt;
    -sDEVICE=pngalpha                                     \&lt;br /&gt;
    -g$2x$3                                             \&lt;br /&gt;
    -dLastPage=1                                          \&lt;br /&gt;
    -c &amp;quot;&amp;lt;&amp;lt;/Install {$4 $5 translate}&amp;gt;&amp;gt; setpagedevice&amp;quot; \&lt;br /&gt;
    -f $1 &lt;br /&gt;
&lt;br /&gt;
where $1x$2=width x height and $4 $5 are the portion excluded from the left and bootom. In this example:&lt;br /&gt;
  ./crop.sh file.pdf 263 236 -42 -510&lt;br /&gt;
&lt;br /&gt;
To make .pdf out try:&lt;br /&gt;
 gs -o out.pdf -sDEVICE=pdfwrite -c &amp;quot;[/CropBox [42 510 305 746] /PAGES pdfmark&amp;quot; -f file.eps&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== '''Extract particula pages from pdf file''' ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  #!/bin/sh&lt;br /&gt;
  #&lt;br /&gt;
  # pdfsplit [input.pdf] [first_page] [last_page] [output.pdf] &lt;br /&gt;
  #&lt;br /&gt;
  # Example: pdfsplit big_file.pdf 10 20 pages_ten_to_twenty.pdf&lt;br /&gt;
  #&lt;br /&gt;
  # written by: Westley Weimer, Wed Mar 19 17:58:09 EDT 2008&lt;br /&gt;
  #&lt;br /&gt;
  # The trick: ghostscript (gs) will do PDF splitting for you, it's just not&lt;br /&gt;
  # obvious and the required defines are not listed in the manual page. &lt;br /&gt;
&lt;br /&gt;
  if [ $# -lt 4 ] &lt;br /&gt;
  then&lt;br /&gt;
          echo &amp;quot;Usage: pdfsplit input.pdf first_page last_page output.pdf&amp;quot;&lt;br /&gt;
          exit 1&lt;br /&gt;
  fi&lt;br /&gt;
  gs -dNOPAUSE -dQUIET -dBATCH -sOutputFile=&amp;quot;$4&amp;quot; -dFirstPage=$2 -dLastPage=$3 -sDEVICE=pdfwrite &amp;quot;$1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== '''Convert eps to jpg using native gs''' ===&lt;br /&gt;
  gs -sDEVICE=jpeg -q -dJPEGQ=100 -dNOPAUSE -dBATCH -dSAFER -r100 -sOutputFile=image.jpg image.eps # ''-r100'' should be changed to ''-r50'' for denser image &lt;br /&gt;
&lt;br /&gt;
=== '''Convert (e)ps to png or gif ''' ===&lt;br /&gt;
&lt;br /&gt;
 name=&amp;quot;imgName&amp;quot;; figdir=&amp;quot;/home/..../Figures&amp;quot;; text=&amp;quot;my image&amp;quot;&lt;br /&gt;
 1. convert $name.ps -depth 8 -alpha off -density 600 &lt;br /&gt;
 2. convert $name.ps -depth 8 -alpha off -density 600 ${figdir}/${name}_large.gif &lt;br /&gt;
 3. convert $name.ps -depth 8 -alpha off -density 600 -resize 320x240 ${figdir}/${name}_large.gif&lt;br /&gt;
 4. convert $name.ps -depth 8 -alpha off -density 600 -gravity Southeast -font helvetica -pointsize 75 \ &lt;br /&gt;
 -draw &amp;quot;text 150,100 '$text'&amp;quot; ${figdir}/${name}_large.gif&lt;br /&gt;
&lt;br /&gt;
1. Resulting image will be named as .eps and will end up at the same place.&lt;br /&gt;
&lt;br /&gt;
2. Resulting image will be named imgName_large.gif and will be placed in \$figdir.&lt;br /&gt;
&lt;br /&gt;
3. Additionally, image can be resized in the same step.&lt;br /&gt;
&lt;br /&gt;
4. Put text into image&lt;br /&gt;
&lt;br /&gt;
=== '''Resize image'''  ===&lt;br /&gt;
  mogrify -trim -resize 70% image.jpg   # or ''-resize 800x600'' for fixed width&lt;br /&gt;
&lt;br /&gt;
=== Screen command ===&lt;br /&gt;
  screen -S name # name a screen&lt;br /&gt;
  screen -ls # list all screens (those named will be easily read)&lt;br /&gt;
  Ctrl+a+d # detach screen&lt;br /&gt;
  screen -r name # attach to a screen&lt;br /&gt;
  screen -S name -X quit # kill detached screen and return to a terminal&lt;br /&gt;
  ls -laR /var/run/screen/ # lists when the screens start running&lt;br /&gt;
&lt;br /&gt;
=== Several images into one ===&lt;br /&gt;
  montage img1.png img2.png img3.png img4.png img5.png img6.png -tile 2x3  -frame 2  -geometry +0+0 out.png &lt;br /&gt;
&lt;br /&gt;
=== Animation on .gif images ===&lt;br /&gt;
  convert -delay 50 img1.gif img2.gif -loop 0 anim.gif&lt;br /&gt;
&lt;br /&gt;
== Some cool stuff ==&lt;br /&gt;
&lt;br /&gt;
* Very nice themes for Ubuntu 10.04&lt;br /&gt;
&lt;br /&gt;
    sudo add-apt-repository ppa:bisigi&lt;br /&gt;
    sudo aptitude update&lt;br /&gt;
    sudo aptitude install bisigi-themes&lt;br /&gt;
&lt;br /&gt;
* Convert youtube .flv to .mp3 ([http://ubuntuforums.org/showthread.php?t=1117283 FORUM])&lt;br /&gt;
   sudo apt-get install youtube-dl&lt;br /&gt;
   sudo youtube-dl -U&lt;br /&gt;
   sudo youtube-dl -U&lt;br /&gt;
   sudo apt-get install ffmpeg libavcodec-unstripped-52&lt;br /&gt;
   sudo apt-get install ubuntu-restricted-extras &lt;br /&gt;
   # Example:&lt;br /&gt;
   youtube-dl http://www.youtube.com/watch?v=Md7IhGYKncs&lt;br /&gt;
   ffmpeg -i Md7IhGYKncs.flv -acodec libmp3lame -ab 128 indiana.mp3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Install IRAF in Ubuntu 16 with Anaconda ==&lt;br /&gt;
&lt;br /&gt;
Source: https://www.anaconda.com/download/#_unix&lt;br /&gt;
&lt;br /&gt;
First install the following libs:&lt;br /&gt;
&lt;br /&gt;
   sudo apt-get install libc6:i386 libz1:i386 libncurses5:i386 libbz2-1.0:i386 libuuid1:i386 libxcb1:i386 &lt;br /&gt;
   sudo apt-get install libxmu-dev:i386&lt;br /&gt;
&lt;br /&gt;
Then download Anaconda from https://www.continuum.io/downloads&lt;br /&gt;
&lt;br /&gt;
   cd /home/&amp;lt;user_name&amp;gt;/&lt;br /&gt;
   bash Anaconda2-4.4.0-Linux-x86_64.sh&lt;br /&gt;
   conda config --add channels http://ssb.stsci.edu/astroconda&lt;br /&gt;
   conda create -n iraf python=2.7 iraf-all pyraf-all stsci&lt;br /&gt;
   source activate iraf&lt;br /&gt;
   mkiraf&lt;br /&gt;
   &amp;lt;set to xgterm&amp;gt;&lt;br /&gt;
   cl&lt;br /&gt;
   ...&lt;br /&gt;
   source deactivate iraf&lt;br /&gt;
      &lt;br /&gt;
Pyraf also works in a standard way...&lt;/div&gt;</summary>
		<author><name>Ana.Lalovic</name></author>
		
	</entry>
</feed>