APSF //- Compute field rotation and maximum exposure time for alt/az mounts //- Paul Rodman July-Nov, 2007 //- //- This script computes the rotation rate of the FOV for each user object. //- From the camera sensor pixel dimensions, the pixel motion at the //- corners of the sensor is computed, and from a given blur size (in pixels) //- the maximum exposure time can be computed and placed in a user field. //- //- V1.0 2007/07/31 //- Original release. //- V1.1 2007/09/23 //- Avoid problems if no site is specified. //- V1.2 2007/11/08 //- Display "None" if rotation rate is extrememly small or zero. sub UserField(n as integer, fnumber as integer, assigns s as string) // Stash string in specified user field // (a good reason to add indexed user field to the next version of the application...) select case fnumber+1 case 1 Obj(n).User1=s case 2 Obj(n).User2=s case 3 Obj(n).User3=s case 4 Obj(n).User4=s end select end sub dim i,PixelsX,PixelsY as integer dim Latitude,Altitude,Azimuth,Rotation,PixelAngle as double dim MaxBlur as double dim computeRotationRate,computePixelRate, computeMaxTime as boolean dim fieldRotationRate, fieldPixelRate, fieldMaxTime as integer dim flds(-1),s as string const DegreesToRadians = 0.01745329252 const RadiansToDegrees = 57.295779513 if currentSite=nil then print "Plan must specify a a Current Site" return end if flds.Append "User Field 1" flds.Append "User Field 2" flds.Append "User Field 3" flds.Append "User Field 4" // Restore parameters from last run PixelsX = RestoreIntegerValue("PixelsX",692) // # Pixels on long side of sensor PixelsY = RestoreIntegerValue("PixelsY",504) // # Pixels on short side of sensor MaxBlur = RestoreDoubleValue("MaxBlur",1) // Maximum blur size in pixels computeRotationRate = RestoreBooleanValue("computeRotationRate",true) fieldRotationRate = RestoreIntegerValue("fieldRotationRate",0) computePixelRate = RestoreBooleanValue("computePixelRate",true) fieldPixelRate = RestoreIntegerValue("fieldPixelRate",1) computeMaxTime = RestoreBooleanValue("computeMaxTime",true) fieldMaxTime = RestoreIntegerValue("fieldMaxTime",2) // Setuip dialog to change parameters SetIntegerParameter("Sensor pixels (long edge)",PixelsX,1,4096) SetIntegerParameter("Sensor pixels (short edge)",PixelsY,1,4096) SetDoubleParameter("Max. blur size (pixels)",MaxBlur) SetBooleanParameter("Compute Field Rotation (arcsec/sec)",computeRotationRate) SetPopupParameter("Field Rotation output",fieldRotationRate,flds) ParameterDependency("Field Rotation output","Compute Field Rotation (arcsec/sec)") SetBooleanParameter("Compute Pixel Rotation (pixel/sec)",computePixelRate) SetPopupParameter("Pixel Rotation output",fieldPixelRate,flds) ParameterDependency("Pixel Rotation output","Compute Pixel Rotation (pixel/sec)") SetBooleanParameter("Compute Max. Exposure (sec)",computeMaxTime) SetPopupParameter("Max. Exposure output",fieldMaxTime,flds) ParameterDependency("Max. Exposure output","Compute Max. Exposure (sec)") if not EditParameters("Compute Field Rotation") then return PixelsX=GetIntegerParameter("Sensor pixels (long edge)") PixelsY=GetIntegerParameter("Sensor pixels (short edge)") MaxBlur=GetDoubleParameter("Max. blur size (pixels)") computeRotationRate=GetBooleanParameter("Compute Field Rotation (arcsec/sec)") fieldRotationRate=GetPopupParameter("Field Rotation output") computePixelRate=GetBooleanParameter("Compute Pixel Rotation (pixel/sec)") fieldPixelRate=GetPopupParameter("Pixel Rotation output") computeMaxTime=GetBooleanParameter("Compute Max. Exposure (sec)") fieldMaxTime=GetPopupParameter("Max. Exposure output") // Save parameters for next run SaveIntegerValue("PixelsX",PixelsX) SaveIntegerValue("PixelsY",PixelsY) SaveDoubleValue("MaxBlur",MaxBlur) SaveBooleanValue("computeRotationRate",computeRotationRate) SaveIntegerValue("fieldRotationRate",fieldRotationRate) SaveBooleanValue("computePixelRate",computePixelRate) SaveIntegerValue("fieldPixelRate",fieldPixelRate) SaveBooleanValue("computeMaxTime",computeMaxTime) SaveIntegerValue("fieldMaxTime",fieldMaxTime) Latitude = CurrentSite.Latitude*DegreesToRadians // Calculate angular size of outer pixels in " PixelAngle = atan(1.414/(0.5*sqrt(PixelsX*PixelsX+PixelsY*PixelsY)))*RadiansToDegrees*3600.0 // Set user field column headings if computeRotationRate then UserColumnNumeric(fieldRotationRate+1,"Rotation (arcsec/sec)",2) if computePixelRate then UserColumnNumeric(fieldPixelRate+1,"Rotation (pixel/sec)",3) if computeMaxTime then UserColumnNumeric(fieldMaxTime+1,"Max Exposure (sec)",1) // For each object for i=1 to nObjects Altitude=Obj(i).Altitude*DegreesToRadians if Altitude<90.0 then Azimuth=Obj(i).Azimuth*DegreesToRadians // Compute rotation rate in "/sec Rotation = 15.0 * cos(Latitude) * cos(Azimuth) / cos(Altitude) // Stash results in user fields if computeRotationRate then if abs(Rotation)<0.005 then UserField(i,fieldRotationRate)="None" else UserField(i,fieldRotationRate)=format(Rotation,"-0.00") end if end if if computePixelRate then if abs(Rotation)<0.005 then UserField(i,fieldPixelRate)="None" else UserField(i,fieldPixelRate)=format(abs(Rotation)/(PixelAngle),"-0.000") end if end if if computeMaxTime then if abs(Rotation)<0.005 then UserField(i,fieldMaxTime)="n/a" else UserField(i,fieldMaxTime)=format(MaxBlur/(abs(Rotation)/(PixelAngle)),"-0.0") end if end if end if next