Jump to content

Solar Enthusiasts: Scripts to enjoy a "3D solar movie"


rudi
 Share

Recommended Posts

Hi.

You are a solar enthusiast?

for my personal fun I wrote these two scripts.

  • The first one is downloading all the JPG solar pictures, starting at a given date.
  • the 2nd one will display them in an Autoit GUI, with an adjustable image difference for your right and left eye:

Screenshot-Solar-JPGs.jpg.de28aef2f6ef1e

"Stare through" your monitor, so that your left eye will focus the left image, your right eye the right image, then you will recognize the 3D effect.

 

If you have difficulties to "match" the left / right image to your left / right eye, then ...

  1. decrease the GUI's size (PAGE-DN), until the "image-middle-distance" is a bit BELOW your eye's distance (depends on your monitor's size and your physiognomy)
  2. put your face very close to your monitor, then slowly fade back, until you will recognize to see virtually THREE images
  3. Wait a moment to recognize the 3D effect of the "middle image"
  4. Concentrate on this "middle image" and it's 3D effect
  5. AVOID rotating or moving your head in any direction, except forward/backward! This propably will kill down the focus, if you've had difficulties to get it in the beginning!
  6. Try to SLOWLY fade back with your face even more, until you have reached a comfortable distance.
  7. Now use PAGE-UP, do increase the GUI's (the images) size: Once you've caught the 3D "match", you can usually increase the size to values, you would have never ever been able to "match" at the first time. (The downloaded images are 1024 x 1024 pixels)

 

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_Description=Display NASA JPG solar pics as a 3D movie
#AutoIt3Wrapper_Res_Fileversion=1.0.0.7
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#AutoIt3Wrapper_Res_LegalCopyright=Rudi Thilo
#AutoIt3Wrapper_Res_SaveSource=y
://////=__=+
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****


#cs
    autoit v3.3.12.0
    author: Rudi Thilo +49 171 685 9 685
    Download the solar JPG pictures of NASA from the subfolders of the URL specified as first variable declaration
    
    1.) download the JPGs using this script
    2.) Use "Solar-GUI-2.au3 to display them as a movie inside an Autoit3 GUI as a "poor-man's-3D-cinema"
    Both scripts have to be in the same folder.
    have fun! :D
#ce


#include <Inet.au3>
#include <Date.au3>


$url = "http://sdo.gsfc.nasa.gov/assets/img/browse/"
$Start = "2015/01/01"
$NextDate = $Start

$RegExJpgName = '(.*?<a href=")([\d_]+?_1024_0193\.jpg)(">.*)' ; $2 returns the JPG file name. Size 1024x1024, Picture colouring type 0193 (whatsoever that exactly means ;-)

$SolarFolder = @ScriptDir & "\SolarJPGs\"
DirCreate($SolarFolder)
ShellExecute($SolarFolder)

HttpSetProxy(1) ; direct access


While (_DateDiff("D", $NextDate, _NowCalcDate()) > -1)
    $NextFolder = $url & $NextDate & "/"
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') :     $NextFolder = ' & $NextFolder & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
    GetJPGs($NextFolder)
    $NextDate = _DateAdd("D", 1, $NextDate)
WEnd




Func GetJPGs($_URL)
    $page = _INetGetSource($_URL)
    $aPage = StringSplit($page, "<tr>", 1)
    if @error then Exit
    For $a = 1 To $aPage[0]
        If StringRegExp($aPage[$a], $RegExJpgName) Then
            $_JPG = StringStripWS(StringRegExpReplace($aPage[$a], $RegExJpgName, "$2"), 1 + 2)
            $_NextURL = $_URL & $_JPG
            $_NextJPG = $SolarFolder & $_JPG
            If FileExists($_NextJPG) Then ContinueLoop ; that file has been downloaded before ALREADY
            ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $_NextJPG = ' & $_NextJPG & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
            $result = InetGet($_NextURL, $_NextJPG, 1 + 2, 1)
        EndIf
    Next
EndFunc   ;==>GetJPGs

 

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_Description=Display NASA JPG solar pics as a 3D movie
#AutoIt3Wrapper_Res_Fileversion=2.0.0.17
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#AutoIt3Wrapper_Res_LegalCopyright=Rudi Thilo
#AutoIt3Wrapper_Res_SaveSource=y
://////=__=+
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs
    autoit v3.3.12.0
    display the previously downloaded solar images as a movie in one Autoit3 GUI, to get some 3D impression
    use ARROW-UP to increase the GUI's size
    use ARROW-DOWN to decrease the GUI's size
    use LEFT-ARROW to run the movie backward
    use RIGHT-ARROW to run the movie forward
    use PAGEUP to increase the delta between the two images (more 3D effect)
    use PAGEDN to decrease the delta between the two images. Negative values will give you a strange effect
    use ESC to close the program

    have fun! :D
#ce


#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <Misc.au3>
#include <file.au3>


$SolarFolder = @ScriptDir & "\SolarJPGs\"

#Region Fill array with all found JPG files
$aJPGs = _FileListToArray($SolarFolder, "*.jpg", 1, 1)
If @error Then
    MsgBox(0, "Solar JPGs", "No JGP files found in path" & @CRLF & $SolarFolder)
    Exit
EndIf
_ArraySort($aJPGs, 0, 1)
#EndRegion Fill array with all found JPG files

$Delta = 3
$forward = True

$LastDate = StringLeft($aJPGs[1], 4) & "-" & StringMid($aJPGs[1], 5, 2) & "-" & StringMid($aJPGs[1], 7, 2)

Local $hDLL = DllOpen("user32.dll")
AdlibRegister("ReadKeys")

$h = 300
$w = $h * 2
$margin = 2

$GuiTitle = "solar movie, " & $h & " px, "

$Gui = GUICreate($GuiTitle & $LastDate, $w + $margin, $h + $margin)
$Left = GUICtrlCreatePic($aJPGs[1 + $Delta], $margin, $margin, $w / 2 - $margin * 2, $h - $margin * 2)
$Right = GUICtrlCreatePic($aJPGs[1], $w / 2 + $margin, $margin, $w / 2 - $margin * 2, $h - $margin * 2)
GUISetState()



$pointer = 1

While 1
    If ($pointer + $Delta) > (UBound($aJPGs) - 1) Or ($pointer > UBound($aJPGs)) Then
        MsgBox(0, "", "Last image reached." & @CRLF & @CRLF & "Changing direction to reverse now...", 3)
        $forward = False
        $pointer -= 1
    ElseIf ($pointer < 1) Or ($pointer + $Delta) < 1 Then
        MsgBox(0, "", "First image reached." & @CRLF & @CRLF & "Changing direction to forward now...", 3)
        $forward = True
        $pointer += 1
    EndIf
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ConsoleWrite("close erkannt" & @CRLF)
            #Region --- CodeWizard generated code Start ---
            ;MsgBox features: Title=Yes, Text=Yes, Buttons=Yes and No, Default Button=Second, Icon=Question, Timeout=5 ss, Miscellaneous=Top-most attribute
            If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
            $iMsgBoxAnswer = MsgBox(262436, "ESC recognized", "Do you want to terminate this program?", 5)
            Select
                Case $iMsgBoxAnswer = 6 ;Yes
                    Exit
                Case $iMsgBoxAnswer = 7 ;No

                Case $iMsgBoxAnswer = -1 ;Timeout

            EndSelect
            #EndRegion --- CodeWizard generated code Start ---
    EndSwitch

    $NextName = $aJPGs[$pointer + $Delta]
    $NextName = StringTrimLeft($NextName, StringInStr($NextName, "\", 0, -1))
    $NextDate = StringLeft($NextName, 4) & "-" & StringMid($NextName, 5, 2) & "-" & StringMid($NextName, 7, 2)
    If $NextDate <> $LastDate Then
        $LastDate = $NextDate
        AdjustTitle()
    EndIf
    $L = $aJPGs[$pointer + $Delta]
    $R = $aJPGs[$pointer]
    GUICtrlSetImage($Left, $L)
    GUICtrlSetImage($Right, $R)

    If $forward Then
        $pointer += 1
    Else
        $pointer -= 1
    EndIf
WEnd


Func ReadKeys()
    $aPos = WinGetPos($Gui)
    If _IsPressed("26", $hDLL) Then ; UP arrow key
        $h += 2
        $w = $h * 2
        WinMove($Gui, "", $aPos[0] - 1, $aPos[1] - 1, $w + $margin * 4, $h + $margin * 2 + 20) ; symmetrically expand one pixel in each direction
        AdjustTitle()
        GUICtrlDelete($Left)
        GUICtrlDelete($Right)
        $Left = GUICtrlCreatePic($L, $margin, $margin, $w / 2 - $margin * 2, $h - $margin * 2)
        $Right = GUICtrlCreatePic($R, $w / 2 + $margin, $margin, $w / 2 - $margin * 2, $h - $margin * 2)
    ElseIf _IsPressed("28", $hDLL) Then ; DOWN arrow key
        $h -= 2
        $w = $h * 2
        WinMove($Gui, "", $aPos[0] + 1, $aPos[1] + 1, $w + $margin * 4, $h + $margin * 2 + 20) ; symmetrically shrink one pixel in each direction
        AdjustTitle()
        GUICtrlDelete($Left)
        GUICtrlDelete($Right)
        $Left = GUICtrlCreatePic($L, $margin, $margin, $w / 2 - $margin * 2, $h - $margin * 2)
        $Right = GUICtrlCreatePic($R, $w / 2 + $margin, $margin, $w / 2 - $margin * 2, $h - $margin * 2)
    ElseIf _IsPressed("21", $hDLL) Then ; PAGE-UP key
        $Delta += 1
        If ($pointer + $Delta) > (UBound($aJPGs) - 1) Then
            MsgBox(0, "", "The End")
            Exit
        EndIf
        AdjustTitle()
    ElseIf _IsPressed("22", $hDLL) Then ; PAGE-DOWN key
        $Delta -= 1
        AdjustTitle()
    ElseIf _IsPressed("25", $hDLL) Then ; LEFT cursor key
        $forward = False
    ElseIf _IsPressed("27", $hDLL) Then ; RIGHT cursor key
        $forward = True
    EndIf
EndFunc   ;==>ReadKeys



Func AdjustTitle()
    $GuiTitle = "solar movie, " & $h & " px, D: " & $Delta & " " & $LastDate
    WinSetTitle($Gui, "", $GuiTitle)
EndFunc   ;==>AdjustTitle

Regards, Rudi.

Edited by rudi

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...