Skip to content

Instantly share code, notes, and snippets.

@shlomiv
Last active August 26, 2018 07:45
Show Gist options
  • Save shlomiv/653b2704a5f446632fd4346f8055d86b to your computer and use it in GitHub Desktop.
Save shlomiv/653b2704a5f446632fd4346f8055d86b to your computer and use it in GitHub Desktop.
Windows bash script to automatically convert NEF to jpg, plate solve them using the wonderful "All Sky Plate Solver", and then automatically display the image's location (and orientation) in Stellarium.
#!/bin/bash
if [ $# -eq 0 ]
then
echo "Usage: solve.sh windows-style-raw-file-with-path [focal length] [pixel size]"
echo
echo 'e.g: ./solve.sh "C:\Users\astroman\Pictures\digiCamControl\crescent nebula\DSC_0027.nef"'
echo
echo "Converts NEF to small jpeg using nconvert (XnView), plate-solves it using the great 'All Sky Plate Solver' (http://www.astrogb.com/astrogb/All_Sky_Plate_Solver.html), and showing the position and rotation of the sensor in stellarium using the remote control plugin. (http://stellarium.org/doc/0.15/remoteControlDoc.html)"
echo "By Shlomi Vaknin"
exit
fi
FILE_RAW=$1
FILE=${FILE_RAW%.[Nn][Ee][Ff]}.jpg
FILE_LINUX=/mnt/c${FILE#'C:'}
FILE_LINUX=$(echo "/$FILE_LINUX" | sed 's/\\/\//g' | sed 's/://')
if [ -e "$FILE_LINUX" ]
then
echo "jpg already exists, continuing.."
else
echo "Convert nef to jpg"
/mnt/c/Program\ Files\ \(x86\)/XnView/nconvert.exe -quiet -out "jpeg" -q 90 -half_res -resize 50% -o "$FILE_LINUX" "$FILE_RAW"
fi
# These numbers are matching my telescope and the conversion above. If these numbers dont work, use the GUI's "Setting Assistant" (which uses Astronomy.net online tool).
RES=$FILE.txt
FL=${2:-186}
pz=${3:-3.9}
echo "Solving (Focal Length $FL, Pixel Size $pz)..."
/mnt/c/Program\ Files\ \(x86\)/PlateSolver/PlateSolver.exe /solvefile "$FILE" "$RES" $FL $pz
echo "Done solving."
RES_LINUX=/mnt/c${RES#'C:'}
RES_LINUX=$(echo "/$RES_LINUX" | sed 's/\\/\//g' | sed 's/://')
if [ -e "$RES_LINUX" ]
then
content=( $(cat "$RES_LINUX") )
status=${content[0]::-1}
if [[ $status == OK ]]; then
echo "Solving success!"
RA=${content[1]::-1}
DEC=${content[2]::-1}
ROT=${content[6]::-1}
echo "Pointing stellarium to $RA, $DEC and rotate by $ROT degrees"
curl --data "code=
core.moveToRaDec ($RA, $DEC);
Oculars.ccdRotationReset();
Oculars.rotateCCD($ROT)
Oculars.toggleCCD (true);" http://localhost:8090/api/scripts/direct
else
echo "Solving failed.. MAKE SURE IMAGE IS FOCUSED! This script is configured for prime focus, try to find out what pz (pixel_size) should really be in the GUI. "
fi
else echo "Solving failed.."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment