This repository has been archived by the owner on Jun 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
alpaca.py
1841 lines (1331 loc) · 58.1 KB
/
alpaca.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""Wraps the HTTP requests for the ASCOM Alpaca API into pythonic classes with methods.
Attributes:
DEFAULT_API_VERSION (int): Default Alpaca API spec to use if none is specified when
needed.
"""
from datetime import datetime
from typing import Optional, Union, List, Dict, Mapping, Any
import dateutil.parser
import requests
DEFAULT_API_VERSION = 1
class Device:
"""Common methods across all ASCOM Alpaca devices.
Attributes:
address (str): Domain name or IP address of Alpaca server.
Can also specify port number if needed.
device_type (str): One of the recognised ASCOM device types
e.g. telescope (must be lower case).
device_number (int): Zero based device number as set on the server (0 to
4294967295).
protocall (str): Protocall used to communicate with Alpaca server.
api_version (int): Alpaca API version.
base_url (str): Basic URL to easily append with commands.
"""
def __init__(
self,
address: str,
device_type: str,
device_number: int,
protocall: str,
api_version: int,
):
"""Initialize Device object."""
self.address = address
self.device_type = device_type
self.device_number = device_number
self.api_version = api_version
self.base_url = "%s://%s/api/v%d/%s/%d" % (
protocall,
address,
api_version,
device_type,
device_number,
)
def action(self, Action: str, *Parameters):
"""Access functionality beyond the built-in capabilities of the ASCOM device interfaces.
Args:
Action (str): A well known name that represents the action to be carried out.
*Parameters: List of required parameters or empty if none are required.
"""
return self._put("action", Action=Action, Parameters=Parameters)["Value"]
def commandblind(self, Command: str, Raw: bool):
"""Transmit an arbitrary string to the device and does not wait for a response.
Args:
Command (str): The literal command string to be transmitted.
Raw (bool): If true, command is transmitted 'as-is'.
If false, then protocol framing characters may be added prior to
transmission.
"""
self._put("commandblind", Command=Command, Raw=Raw)
def commandbool(self, Command: str, Raw: bool):
"""Transmit an arbitrary string to the device and wait for a boolean response.
Args:
Command (str): The literal command string to be transmitted.
Raw (bool): If true, command is transmitted 'as-is'.
If false, then protocol framing characters may be added prior to
transmission.
"""
return self._put("commandbool", Command=Command, Raw=Raw)["Value"]
def commandstring(self, Command: str, Raw: bool):
"""Transmit an arbitrary string to the device and wait for a string response.
Args:
Command (str): The literal command string to be transmitted.
Raw (bool): If true, command is transmitted 'as-is'.
If false, then protocol framing characters may be added prior to
transmission.
"""
return self._put("commandstring", Command=Command, Raw=Raw)["Value"]
def connected(self, Connected: Optional[bool] = None):
"""Retrieve or set the connected state of the device.
Args:
Connected (bool): Set True to connect to device hardware.
Set False to disconnect from device hardware.
Set None to get connected state (default).
"""
if Connected == None:
return self._get("connected")
self._put("connected", Connected=Connected)
def description(self) -> str:
"""Get description of the device."""
return self._get("name")
def driverinfo(self) -> List[str]:
"""Get information of the device."""
return [i.strip() for i in self._get("driverinfo").split(",")]
def driverversion(self) -> str:
"""Get string containing only the major and minor version of the driver."""
return self._get("driverversion")
def interfaceversion(self) -> int:
"""ASCOM Device interface version number that this device supports."""
return self._get("interfaceversion")
def name(self) -> str:
"""Get name of the device."""
return self._get("name")
def supportedactions(self) -> List[str]:
"""Get list of action names supported by this driver."""
return self._get("supportedactions")
def _get(self, attribute: str, **data):
"""Send an HTTP GET request to an Alpaca server and check response for errors.
Args:
attribute (str): Attribute to get from server.
**data: Data to send with request.
"""
response = requests.get("%s/%s" % (self.base_url, attribute), data=data)
self.__check_error(response)
return response.json()["Value"]
def _put(self, attribute: str, **data):
"""Send an HTTP PUT request to an Alpaca server and check response for errors.
Args:
attribute (str): Attribute to put to server.
**data: Data to send with request.
"""
response = requests.put("%s/%s" % (self.base_url, attribute), data=data)
self.__check_error(response)
return response.json()
def __check_error(self, response: requests.Response):
"""Check response from Alpaca server for Errors.
Args:
response (Response): Response from Alpaca server to check.
"""
j = response.json()
if j["ErrorNumber"] != 0:
raise NumericError(j["ErrorNumber"], j["ErrorMessage"])
elif response.status_code == 400 or response.status_code == 500:
raise ErrorMessage(j["Value"])
class Switch(Device):
"""Switch specific methods."""
def __init__(
self,
address: str,
device_number: int,
protocall: str = "http",
api_version: int = DEFAULT_API_VERSION,
):
"""Initialize Switch object."""
super().__init__(address, "switch", device_number, protocall, api_version)
def maxswitch(self) -> int:
"""Count of switch devices managed by this driver.
Returns:
Number of switch devices managed by this driver. Devices are numbered from 0
to MaxSwitch - 1.
"""
return self._get("maxswitch")
def canwrite(self, Id: Optional[int] = 0) -> bool:
"""Indicate whether the specified switch device can be written to.
Notes:
Devices are numbered from 0 to MaxSwitch - 1.
Args:
Id (int): The device number.
Returns:
Whether the specified switch device can be written to, default true. This is
false if the device cannot be written to, for example a limit switch or a
sensor.
"""
return self._get("canwrite", Id=Id)
def getswitch(self, Id: Optional[int] = 0) -> bool:
"""Return the state of switch device id as a boolean.
Notes:
Devices are numbered from 0 to MaxSwitch - 1.
Args:
Id (int): The device number.
Returns:
State of switch device id as a boolean.
"""
return self._get("getswitch", Id=Id)
def getswitchdescription(self, Id: Optional[int] = 0) -> str:
"""Get the description of the specified switch device.
Notes:
Devices are numbered from 0 to MaxSwitch - 1.
Args:
Id (int): The device number.
Returns:
Description of the specified switch device.
"""
return self._get("getswitchdescription", Id=Id)
def getswitchname(self, Id: Optional[int] = 0) -> str:
"""Get the name of the specified switch device.
Notes:
Devices are numbered from 0 to MaxSwitch - 1.
Args:
Id (int): The device number.
Returns:
Name of the specified switch device.
"""
return self._get("getswitchname", Id=Id)
def getswitchvalue(self, Id: Optional[int] = 0) -> str:
"""Get the value of the specified switch device as a double.
Notes:
Devices are numbered from 0 to MaxSwitch - 1.
Args:
Id (int): The device number.
Returns:
Value of the specified switch device.
"""
return self._get("getswitchvalue", Id=Id)
def minswitchvalue(self, Id: Optional[int] = 0) -> str:
"""Get the minimum value of the specified switch device as a double.
Notes:
Devices are numbered from 0 to MaxSwitch - 1.
Args:
Id (int): The device number.
Returns:
Minimum value of the specified switch device as a double.
"""
return self._get("minswitchvalue", Id=Id)
def setswitch(self, Id: int, State: bool):
"""Set a switch controller device to the specified state, True or False.
Notes:
Devices are numbered from 0 to MaxSwitch - 1.
Args:
Id (int): The device number.
State (bool): The required control state (True or False).
"""
self._put("setswitch", Id=Id, State=State)
def setswitchname(self, Id: int, Name: str):
"""Set a switch device name to the specified value.
Notes:
Devices are numbered from 0 to MaxSwitch - 1.
Args:
Id (int): The device number.
Name (str): The name of the device.
"""
self._put("setswitchname", Id=Id, Name=Name)
def setswitchvalue(self, Id: int, Value: float):
"""Set a switch device value to the specified value.
Notes:
Devices are numbered from 0 to MaxSwitch - 1.
Args:
Id (int): The device number.
Value (float): Value to be set, between MinSwitchValue and MaxSwitchValue.
"""
self._put("setswitchvalue", Id=Id, Value=Value)
def switchstep(self, Id: Optional[int] = 0) -> str:
"""Return the step size that this device supports.
Return the step size that this device supports (the difference between
successive values of the device).
Notes:
Devices are numbered from 0 to MaxSwitch - 1.
Args:
Id (int): The device number.
Returns:
Maximum value of the specified switch device as a double.
"""
return self._get("switchstep", Id=Id)
class SafetyMonitor(Device):
"""Safety monitor specific methods."""
def __init__(
self,
address: str,
device_number: int,
protocall: str = "http",
api_version: int = DEFAULT_API_VERSION,
):
"""Initialize SafetyMonitor object."""
super().__init__(
address, "safetymonitor", device_number, protocall, api_version
)
def issafe(self) -> bool:
"""Indicate whether the monitored state is safe for use.
Returns:
True if the state is safe, False if it is unsafe.
"""
return self._get("issafe")
class Dome(Device):
"""Dome specific methods."""
def __init__(
self,
address: str,
device_number: int,
protocall: str = "http",
api_version: int = DEFAULT_API_VERSION,
):
"""Initialize Dome object."""
super().__init__(address, "dome", device_number, protocall, api_version)
def altitude(self) -> float:
"""Dome altitude.
Returns:
Dome altitude (degrees, horizon zero and increasing positive to 90 zenith).
"""
return self._get("altitude")
def athome(self) -> bool:
"""Indicate whether the dome is in the home position.
Notes:
This is normally used following a findhome() operation. The value is reset
with any azimuth slew operation that moves the dome away from the home
position. athome() may also become true durng normal slew operations, if the
dome passes through the home position and the dome controller hardware is
capable of detecting that; or at the end of a slew operation if the dome
comes to rest at the home position.
Returns:
True if dome is in the home position.
"""
return self._get("athome")
def atpark(self) -> bool:
"""Indicate whether the telescope is at the park position.
Notes:
Set only following a park() operation and reset with any slew operation.
Returns:
True if the dome is in the programmed park position.
"""
return self._get("atpark")
def azimuth(self) -> float:
"""Dome azimuth.
Returns:
Dome azimuth (degrees, North zero and increasing clockwise, i.e., 90 East,
180 South, 270 West).
"""
return self._get("azimuth")
def canfindhome(self) -> bool:
"""Indicate whether the dome can find the home position.
Returns:
True if the dome can move to the home position.
"""
return self._get("canfindhome")
def canpark(self) -> bool:
"""Indicate whether the dome can be parked.
Returns:
True if the dome is capable of programmed parking (park() method).
"""
return self._get("canpark")
def cansetaltitude(self) -> bool:
"""Indicate whether the dome altitude can be set.
Returns:
True if driver is capable of setting the dome altitude.
"""
return self._get("cansetaltitude")
def cansetazimuth(self) -> bool:
"""Indicate whether the dome azimuth can be set.
Returns:
True if driver is capable of setting the dome azimuth.
"""
return self._get("cansetazimuth")
def cansetpark(self) -> bool:
"""Indicate whether the dome park position can be set.
Returns:
True if driver is capable of setting the dome park position.
"""
return self._get("cansetpark")
def cansetshutter(self) -> bool:
"""Indicate whether the dome shutter can be opened.
Returns:
True if driver is capable of automatically operating shutter.
"""
return self._get("cansetshutter")
def canslave(self) -> bool:
"""Indicate whether the dome supports slaving to a telescope.
Returns:
True if driver is capable of slaving to a telescope.
"""
return self._get("canslave")
def cansyncazimuth(self) -> bool:
"""Indicate whether the dome azimuth position can be synched.
Notes:
True if driver is capable of synchronizing the dome azimuth position using
the synctoazimuth(float) method.
Returns:
True or False value.
"""
return self._get("cansyncazimuth")
def shutterstatus(self) -> int:
"""Status of the dome shutter or roll-off roof.
Notes:
0 = Open, 1 = Closed, 2 = Opening, 3 = Closing, 4 = Shutter status error.
Returns:
Status of the dome shutter or roll-off roof.
"""
return self._get("shutterstatus")
def slaved(self, Slaved: Optional[bool] = None) -> bool:
"""Set or indicate whether the dome is slaved to the telescope.
Returns:
True or False value in not set.
"""
if Slaved == None:
return self._get("slaved")
self._put("slaved", Slaved=Slaved)
def slewing(self) -> bool:
"""Indicate whether the any part of the dome is moving.
Notes:
True if any part of the dome is currently moving, False if all dome
components are steady.
Return:
True or False value.
"""
return self._get("slewing")
def abortslew(self):
"""Immediately cancel current dome operation.
Notes:
Calling this method will immediately disable hardware slewing (Slaved will
become False).
"""
self._put("abortslew")
def closeshutter(self):
"""Close the shutter or otherwise shield telescope from the sky."""
self._put("closeshutter")
def findhome(self):
"""Start operation to search for the dome home position.
Notes:
After home position is established initializes azimuth to the default value
and sets the athome flag.
"""
self._put("findhome")
def openshutter(self):
"""Open shutter or otherwise expose telescope to the sky."""
self._put("openshutter")
def park(self):
"""Rotate dome in azimuth to park position.
Notes:
After assuming programmed park position, sets atpark flag.
"""
self._put("park")
def setpark(self):
"""Set current azimuth, altitude position of dome to be the park position."""
self._put("setpark")
def slewtoaltitude(self, Altitude: float):
"""Slew the dome to the given altitude position."""
self._put("slewtoaltitude", Altitude=Altitude)
def slewtoazimuth(self, Azimuth: float):
"""Slew the dome to the given azimuth position.
Args:
Azimuth (float): Target dome azimuth (degrees, North zero and increasing
clockwise. i.e., 90 East, 180 South, 270 West).
"""
self._put("slewtoazimuth", Azimuth=Azimuth)
def synctoazimuth(self, Azimuth: float):
"""Synchronize the current position of the dome to the given azimuth.
Args:
Azimuth (float): Target dome azimuth (degrees, North zero and increasing
clockwise. i.e., 90 East, 180 South, 270 West).
"""
self._put("synctoazimuth", Azimuth=Azimuth)
class Camera(Device):
"""Camera specific methods."""
def __init__(
self,
address: str,
device_number: int,
protocall: str = "http",
api_version: int = DEFAULT_API_VERSION,
):
"""Initialize Camera object."""
super().__init__(address, "camera", device_number, protocall, api_version)
def bayeroffsetx(self) -> int:
"""Return the X offset of the Bayer matrix, as defined in SensorType."""
return self._get("bayeroffsetx")
def bayeroffsety(self) -> int:
"""Return the Y offset of the Bayer matrix, as defined in SensorType."""
return self._get("bayeroffsety")
def binx(self, BinX: Optional[int] = None) -> int:
"""Set or return the binning factor for the X axis.
Args:
BinX (int): The X binning value.
Returns:
Binning factor for the X axis.
"""
if BinX == None:
return self._get("binx")
self._put("binx", BinX=BinX)
def biny(self, BinY: Optional[int] = None) -> int:
"""Set or return the binning factor for the Y axis.
Args:
BinY (int): The Y binning value.
Returns:
Binning factor for the Y axis.
"""
if BinY == None:
return self._get("biny")
self._put("biny", BinY=BinY)
def camerastate(self) -> int:
"""Return the camera operational state.
Notes:
0 = CameraIdle, 1 = CameraWaiting, 2 = CameraExposing,
3 = CameraReading, 4 = CameraDownload, 5 = CameraError.
Returns:
Current camera operational state as an integer.
"""
return self._get("camerastate")
def cameraxsize(self) -> int:
"""Return the width of the CCD camera chip."""
return self._get("cameraxsize")
def cameraysize(self) -> int:
"""Return the height of the CCD camera chip."""
return self._get("cameraysize")
def canabortexposure(self) -> bool:
"""Indicate whether the camera can abort exposures."""
return self._get("canabortexposure")
def canasymmetricbin(self) -> bool:
"""Indicate whether the camera supports asymmetric binning."""
return self._get("canasymmetricbin")
def canfastreadout(self) -> bool:
"""Indicate whether the camera has a fast readout mode."""
return self._get("canfastreadout")
def cangetcoolerpower(self) -> bool:
"""Indicate whether the camera's cooler power setting can be read."""
return self._get("cangetcoolerpower")
def canpulseguide(self) -> bool:
"""Indicate whether this camera supports pulse guiding."""
return self._get("canpulseguide")
def cansetccdtemperature(self) -> bool:
"""Indicate whether this camera supports setting the CCD temperature."""
return self._get("cansetccdtemperature")
def canstopexposure(self) -> bool:
"""Indicate whether this camera can stop an exposure that is in progress."""
return self._get("canstopexposure")
def ccdtemperature(self) -> float:
"""Return the current CCD temperature in degrees Celsius."""
return self._get("ccdtemperature")
def cooleron(self, CoolerOn: Optional[bool] = None) -> bool:
"""Turn the camera cooler on and off or return the current cooler on/off state.
Notes:
True = cooler on, False = cooler off.
Args:
CoolerOn (bool): Cooler state.
Returns:
Current cooler on/off state.
"""
if CoolerOn == None:
return self._get("cooleron")
self._put("cooleron", CoolerOn=CoolerOn)
def coolerpower(self) -> float:
"""Return the present cooler power level, in percent."""
return self._get("coolerpower")
def electronsperadu(self) -> float:
"""Return the gain of the camera in photoelectrons per A/D unit."""
return self._get("electronsperadu")
def exposuremax(self) -> float:
"""Return the maximum exposure time supported by StartExposure."""
return self._get("exposuremax")
def exposuremin(self) -> float:
"""Return the minimum exposure time supported by StartExposure."""
return self._get("exposuremin")
def exposureresolution(self) -> float:
"""Return the smallest increment in exposure time supported by StartExposure."""
return self._get("exposureresolution")
def fastreadout(self, FastReadout: Optional[bool] = None) -> bool:
"""Set or return whether Fast Readout Mode is enabled.
Args:
FastReadout (bool): True to enable fast readout mode.
Returns:
Whether Fast Readout Mode is enabled.
"""
if FastReadout == None:
return self._get("fastreadout")
self._put("fastreadout", FastReadout=FastReadout)
def fullwellcapacity(self) -> float:
"""Report the full well capacity of the camera.
Report the full well capacity of the camera in electrons, at the current
camera settings (binning, SetupDialog settings, etc.).
Returns:
Full well capacity of the camera.
"""
return self._get("fullwellcapacity")
def gain(self, Gain: Optional[int] = None) -> int:
"""Set or return an index into the Gains array.
Args:
Gain (int): Index of the current camera gain in the Gains string array.
Returns:
Index into the Gains array for the selected camera gain.
"""
if Gain == None:
return self._get("gain")
self._put("gain", Gain=Gain)
def gainmax(self) -> int:
"""Maximum value of Gain."""
return self._get("gainmax")
def gainmin(self) -> int:
"""Minimum value of Gain."""
return self._get("gainmin")
def gains(self) -> List[int]:
"""Gains supported by the camera."""
return self._get("gains")
def hasshutter(self) -> bool:
"""Indicate whether the camera has a mechanical shutter."""
return self._get("hasshutter")
def heatsinktemperature(self) -> float:
"""Return the current heat sink temperature.
Returns:
Current heat sink temperature (called "ambient temperature" by some
manufacturers) in degrees Celsius.
"""
return self._get("heatsinktemperature")
def imagearray(self) -> List[int]:
r"""Return an array of integers containing the exposure pixel values.
Return an array of 32bit integers containing the pixel values from the last
exposure. This call can return either a 2 dimension (monochrome images) or 3
dimension (colour or multi-plane images) array of size NumX * NumY or NumX *
NumY * NumPlanes. Where applicable, the size of NumPlanes has to be determined
by inspection of the returned Array. Since 32bit integers are always returned
by this call, the returned JSON Type value (0 = Unknown, 1 = short(16bit),
2 = int(32bit), 3 = Double) is always 2. The number of planes is given in the
returned Rank value. When de-serialising to an object it helps enormously to
know the array Rank beforehand so that the correct data class can be used. This
can be achieved through a regular expression or by direct parsing of the
returned JSON string to extract the Type and Rank values before de-serialising.
This regular expression accomplishes the extraction into two named groups Type
and Rank ^*"Type":(?<Type>\d*),"Rank":(?<Rank>\d*) which can then be used to
select the correct de-serialisation data class.
Returns:
Array of integers containing the exposure pixel values.
"""
return self._get("imagearray")
def imagearrayvariant(self) -> List[int]:
r"""Return an array of integers containing the exposure pixel values.
Return an array of 32bit integers containing the pixel values from the last
exposure. This call can return either a 2 dimension (monochrome images) or 3
dimension (colour or multi-plane images) array of size NumX * NumY or NumX *
NumY * NumPlanes. Where applicable, the size of NumPlanes has to be determined
by inspection of the returned Array. Since 32bit integers are always returned
by this call, the returned JSON Type value (0 = Unknown, 1 = short(16bit),
2 = int(32bit), 3 = Double) is always 2. The number of planes is given in the
returned Rank value. When de-serialising to an object it helps enormously to
know the array Rank beforehand so that the correct data class can be used. This
can be achieved through a regular expression or by direct parsing of the
returned JSON string to extract the Type and Rank values before de-serialising.
This regular expression accomplishes the extraction into two named groups Type
and Rank ^*"Type":(?<Type>\d*),"Rank":(?<Rank>\d*) which can then be used to
select the correct de-serialisation data class.
Returns:
Array of integers containing the exposure pixel values.
"""
return self._get("imagearrayvariant")
def imageready(self) -> bool:
"""Indicate that an image is ready to be downloaded."""
return self._get("imageready")
def ispulseguiding(self) -> bool:
"""Indicatee that the camera is pulse guideing."""
return self._get("ispulseguiding")
def lastexposureduration(self) -> float:
"""Report the actual exposure duration in seconds (i.e. shutter open time)."""
return self._get("lastexposureduration")
def lastexposurestarttime(self) -> str:
"""Start time of the last exposure in FITS standard format.
Reports the actual exposure start in the FITS-standard
CCYY-MM-DDThh:mm:ss[.sss...] format.
Returns:
Start time of the last exposure in FITS standard format.
"""
return self._get("lastexposurestarttime")
def maxadu(self) -> int:
"""Camera's maximum ADU value."""
return self._get("maxadu")
def maxbinx(self) -> int:
"""Maximum binning for the camera X axis."""
return self._get("maxbinx")
def maxbiny(self) -> int:
"""Maximum binning for the camera Y axis."""
return self._get("maxbiny")
def numx(self, NumX: Optional[int] = None) -> int:
"""Set or return the current subframe width.
Args:
NumX (int): Subframe width, if binning is active, value is in binned
pixels.
Returns:
Current subframe width.
"""
if NumX == None:
return self._get("numx")
self._put("numx", NumX=NumX)
def numy(self, NumY: Optional[int] = None) -> int:
"""Set or return the current subframe height.
Args:
NumX (int): Subframe height, if binning is active, value is in binned
pixels.
Returns:
Current subframe height.
"""
if NumY == None:
return self._get("numy")
self._put("numy", NumY=NumY)
def percentcompleted(self) -> int:
"""Indicate percentage completeness of the current operation.
Returns:
If valid, returns an integer between 0 and 100, where 0 indicates 0%
progress (function just started) and 100 indicates 100% progress (i.e.
completion).
"""
return self._get("percentcompleted")
def pixelsizex(self):
"""Width of CCD chip pixels (microns)."""
return self._get("pixelsizex")
def pixelsizey(self):
"""Height of CCD chip pixels (microns)."""
return self._get("pixelsizey")
def readoutmode(self, ReadoutMode: Optional[int] = None) -> int:
"""Indicate the canera's readout mode as an index into the array ReadoutModes."""
if ReadoutMode == None:
return self._get("readoutmode")
self._put("readoutmode", ReadoutMode=ReadoutMode)
def readoutmodes(self) -> List[int]:
"""List of available readout modes."""
return self._get("readoutmodes")
def sensorname(self) -> str:
"""Name of the sensor used within the camera."""
return self._get("sensorname")
def sensortype(self) -> int:
"""Type of information returned by the the camera sensor (monochrome or colour).
Notes:
0 = Monochrome, 1 = Colour not requiring Bayer decoding, 2 = RGGB Bayer
encoding, 3 = CMYG Bayer encoding, 4 = CMYG2 Bayer encoding, 5 = LRGB
TRUESENSE Bayer encoding.
Returns:
Value indicating whether the sensor is monochrome, or what Bayer matrix it
encodes.
"""
return self._get("sensortype")
def setccdtemperature(self, SetCCDTemperature: Optional[float] = None) -> float:
"""Set or return the camera's cooler setpoint (degrees Celsius).
Args:
SetCCDTemperature (float): Temperature set point (degrees Celsius).
Returns:
Camera's cooler setpoint (degrees Celsius).
"""
if SetCCDTemperature == None:
return self._get("setccdtemperature")
self._put("setccdtemperature", SetCCDTemperature=SetCCDTemperature)
def startx(self, StartX: Optional[int] = None) -> int:
"""Set or return the current subframe X axis start position.
Args:
StartX (int): The subframe X axis start position in binned pixels.
Returns: