keepout_path_graphics
Implementation details of util/keepout_path_graphics.py.
keepout_path_graphics: Plot targets, planets, and keepout regions, with optional DRM overlay
For usage, use the -h option. Some options may be described there but not here.
Produces a time-stepped map, in sky coordinates, of stellar targets, planets, keepout regions, and, if a DRM is provided (see below), detections, characterizations, and slews. Output is to a movie (.mp4), or individual frames (.png). Also, some cumulative keepout summary statistics, and plots, can optionally be generated.
DRM or observing-tour display: If pickles summarizing a DRM are supplied (--drm), then the observing tour is loaded and the observations are shown. It is assumed that --drm and --spc are used together.
Typical usage:
keepout_path_graphics.py -s 0 -l 0.2 -d 0.5 -m $HOME/keepout.mp4 ./sampleScript_coron.json
where:
- -s is the start-time of the movie if zero, the start-time from the script is used. if a float in [0,1], the movie is started that proportion of the way through the mission. if a number <= 10000 is given, this is the offset from mission start in days if a number > 10000 is given, this is the MJD start time.
- -l is the length in years if zero is given (-l 0), the duration from the script is used.
- -d is the delta-t between frames in days
- -m is the name of the movie
optionally:
- -e -- use equatorial coordinates as opposed to ra/dec, HIGHLY recommended
- -C -- make a coronagraph-only movie, even if a starshade is present. (only affects movie and final frame, not cumulative keepout)
- -f DIR -- the directory name for .png frame-by-frame output
- -c DIR -- the directory name for cumulative keepout output
- --drm FILE -- the file containing the DRM as a pickle
- --spc FILE -- the file containing the SPC as a pickle
Option for experts only:
- -x SCRIPT -- the given SCRIPT filename is loaded on top of the argument script if the given SCRIPT name begins with !, it is treated as a json literal rather than a filename
GraphicsStyle
Bases: object
Singleton class that holds graphics styles.
Source code in util/keepout_path_graphics.py
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 | |
count2pt(count)
Display "points" (i.e., circle radius in point units) per detection.
Source code in util/keepout_path_graphics.py
230 231 232 | |
count2pt2(count)
Display "points" (i.e., markersize point^2 units) per detection. The relationship between count2pt vs. count2pt2 is empirical.
Source code in util/keepout_path_graphics.py
234 235 236 237 | |
ObserveInfo
Bases: object
Observations made by a mission, in order, as loaded from an external DRM pickle.
Source code in util/keepout_path_graphics.py
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 | |
char_after(day)
Return index of the next characterization AFTER day
Source code in util/keepout_path_graphics.py
497 498 499 500 501 502 503 504 | |
char_before(day)
Return index of the previous characterization BEFORE day
Source code in util/keepout_path_graphics.py
488 489 490 491 492 493 494 495 | |
char_bracket(day)
Return pair of characterization observations bracketing a given day.
Source code in util/keepout_path_graphics.py
476 477 478 479 480 481 482 483 484 485 486 | |
char_to_date(day)
Return all characterization observations up to a given day.
Source code in util/keepout_path_graphics.py
506 507 508 509 510 511 | |
load_from_spc_file(loc, spc)
Load the DRM, and star/planet info from a "spc" file given as an argument. This drm + spc file transfer is compatible the Exosims ipyparallel output.
Source code in util/keepout_path_graphics.py
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | |
lookup(day)
Return index of observation closest to day.
Source code in util/keepout_path_graphics.py
375 376 377 | |
obs_history(day)
Return observation history up to the given day: counts of detections and charaterizations. Each observation fits into one of the cases below. Coded as below, where each is a Counter indexed by star number. dets0 = observation with no detections. dets1 = observation with >=1 detection. chars0 = characterization attempt, failed. chars1 = characterization attempt, success. Could enhance to add another counter, for habitable-zone detections vs. non-HZ detections.
Source code in util/keepout_path_graphics.py
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 | |
obs_summary(day, normal, z0)
Return a summary of observation history up to given day.
If normal is False, it is the last day, and slightly different summary rules hold. The summary is a list of tuples, intended to be: star_number, color, size, extra. In this case, `extra' is a dictionary of point properties, which will be given to the matplotlib circle-plotter. To control plot order, we need to have the base z-order (z0) of the returned summaries. When we need objects to come out on top, we use z0+(dz), as follows: dets: z0; dets-on-top: z0+1; chars: z0+2; chars-on-top: z0:3 Because of closely-packed binaries, it is important to put chars on top.
Source code in util/keepout_path_graphics.py
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 | |
stars_on_slew(day)
Return list of all stars in the characterization-slew-interval containing day.
Source code in util/keepout_path_graphics.py
513 514 515 516 517 | |
tour_summary(args)
Compute and optionally dump tour summary statistics.
Source code in util/keepout_path_graphics.py
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 | |
circle_marker(**given_props)
Return a Line2D with circular markers for an axis legend, given_props over-rides. Some key properties to pass in: markeredgecolor (mec), markeredgewidth (mew), markerfacecolor (mfc), markersize.
Source code in util/keepout_path_graphics.py
699 700 701 702 703 704 705 706 707 708 709 | |
ensure_dir(directory)
Ensure enclosing dir exists, especially in multiprocessing context.
Source code in util/keepout_path_graphics.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
extract_time(tm)
Unbox a time, if it is boxed, for compatibility with multiple DRMs.
Source code in util/keepout_path_graphics.py
169 170 171 172 173 174 | |
gcp(lon1, lat1, lon2, lat2)
GCP = great circle points from (lon1,lat1) -> (lon2,lat2).
Point-count is auto-determined for smoothness without waste.
Source code in util/keepout_path_graphics.py
532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 | |
get_arrow(lines, length)
"Pick one of the line segments within lines, and make an arrow point along it.
Source code in util/keepout_path_graphics.py
582 583 584 585 586 587 588 589 590 | |
get_char_status(obs)
Utility function, gets char status from a drm observation.
Source code in util/keepout_path_graphics.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | |
get_koangles(OS)
Get koangles array from information in the OpticalSystem. The (un-pythonic) code here is copied from Prototypes/SurveySimulation so that we generate exactly the koangles as expected by the caching mechanism and the Observatory.keepout() method.
Source code in util/keepout_path_graphics.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
get_slew_begin(obs)
Return the time of the beginning of the slew, if any, for obs
Source code in util/keepout_path_graphics.py
205 206 207 208 209 | |
run_max(x)
Return the maximal run of True along each row of a 2d matrix x.
It is assumed that all rows start and end False, with one or more transitions to True along the way. You can False-pad x on left and right to ensure this.
Source code in util/keepout_path_graphics.py
682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 | |
spherical_cap(lon1, lat1, theta)
Return lon-lat point-list of a spherical cap of theta degrees around (lon,lat).
Envision the (lon,lat) point with a line connecting it to the origin of a unit sphere, and then a plane orthogonal to that line. To generate the cap, we construct a basis spanning the plane, and then draw a circle of radius tan(theta) in that plane. Then we extract the lon/lat values of that circle, and turn them into a list of connected segments. This is needed because the lon/lat circle can overflow the edge of the lon/lat plot, and appear as two half-circles.
Source code in util/keepout_path_graphics.py
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 | |
strip_units(x)
Strip astropy units from x.
Source code in util/keepout_path_graphics.py
197 198 199 200 201 202 203 | |
wrap_path(x, y)
Given a path as lists of x's and y's, separate it into contiguous path segments.
The input paths are lists of (lon,lat), and if the jump between adjacent values is too large, this indicates a jump such as a wrap-around from 359.9 -> 0.1 in longitude. Think of a circle in (lon,lat) near the right edge of the plot. We separate the path at these points. The return value looks like: lines = [[(x1, y1), (x2, y2), ...], [(xP, yP), (xP+1, yP+1), ...] , ... ] We also return a boolean, "closed", indicating if the resulting line segments each enclose a closed boundary.
Source code in util/keepout_path_graphics.py
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 | |
wrap_paths(p1, p2)
Construct a path from p1 to p2, allowing for wrap-around of longitude.
Note that latitude does not wrap, because +90 is distinct from -90.
Source code in util/keepout_path_graphics.py
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 | |