Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

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

1001

1002

1003

1004

1005

1006

1007

1008

1009

1010

1011

1012

1013

1014

1015

1016

1017

1018

1019

1020

1021

1022

1023

1024

1025

1026

1027

1028

1029

1030

1031

1032

1033

1034

1035

1036

1037

1038

1039

1040

1041

1042

1043

1044

1045

1046

1047

1048

1049

1050

1051

1052

1053

1054

1055

1056

1057

1058

1059

1060

1061

1062

1063

1064

1065

from builtins import zip 

from builtins import range 

import numpy as np 

from .baseStacker import BaseStacker 

 

__all__ = ['wrapRADec', 'wrapRA', 'inHexagon', 'polygonCoords', 

'RandomDitherFieldPerVisitStacker', 'RandomDitherFieldPerNightStacker', 

'RandomDitherPerNightStacker', 

'SpiralDitherFieldPerVisitStacker', 'SpiralDitherFieldPerNightStacker', 

'SpiralDitherPerNightStacker', 

'HexDitherFieldPerVisitStacker', 'HexDitherFieldPerNightStacker', 

'HexDitherPerNightStacker', 'DefaultDitherStacker', 

'RandomRotDitherPerFilterChangeStacker'] 

 

# Stacker naming scheme: 

# [Pattern]Dither[Field]Per[Timescale]. 

# Timescale indicates how often the dither offset is changed. 

# The presence of 'Field' indicates that a new offset is chosen per field, on the indicated timescale. 

# The absence of 'Field' indicates that all visits within the indicated timescale use the same dither offset. 

 

 

# Original dither stackers (Random, Spiral, Hex) written by Lynne Jones (lynnej@uw.edu) 

# Additional dither stackers written by Humna Awan (humna.awan@rutgers.edu), with addition of 

# constraining dither offsets to be within an inscribed hexagon (code modifications for use here by LJ). 

 

 

def wrapRADec(ra, dec): 

""" 

Wrap RA into 0-2pi and Dec into +/0 pi/2. 

 

Parameters 

---------- 

ra : numpy.ndarray 

RA in radians 

dec : numpy.ndarray 

Dec in radians 

 

Returns 

------- 

numpy.ndarray, numpy.ndarray 

Wrapped RA/Dec values, in radians. 

""" 

# Wrap dec. 

low = np.where(dec < -np.pi / 2.0)[0] 

dec[low] = -1 * (np.pi + dec[low]) 

ra[low] = ra[low] - np.pi 

high = np.where(dec > np.pi / 2.0)[0] 

dec[high] = np.pi - dec[high] 

ra[high] = ra[high] - np.pi 

# Wrap RA. 

ra = ra % (2.0 * np.pi) 

return ra, dec 

 

 

def wrapRA(ra): 

""" 

Wrap only RA values into 0-2pi (using mod). 

 

Parameters 

---------- 

ra : numpy.ndarray 

RA in radians 

 

Returns 

------- 

numpy.ndarray 

Wrapped RA values, in radians. 

""" 

ra = ra % (2.0 * np.pi) 

return ra 

 

 

def inHexagon(xOff, yOff, maxDither): 

""" 

Identify dither offsets which fall within the inscribed hexagon. 

 

Parameters 

---------- 

xOff : numpy.ndarray 

The x values of the dither offsets. 

yoff : numpy.ndarray 

The y values of the dither offsets. 

maxDither : float 

The maximum dither offset. 

 

Returns 

------- 

numpy.ndarray 

Indexes of the offsets which are within the hexagon inscribed inside the 'maxDither' radius circle. 

""" 

# Set up the hexagon limits. 

# y = mx + b, 2h is the height. 

m = np.sqrt(3.0) 

b = m * maxDither 

h = m / 2.0 * maxDither 

# Identify offsets inside hexagon. 

inside = np.where((yOff < m * xOff + b) & 

(yOff > m * xOff - b) & 

(yOff < -m * xOff + b) & 

(yOff > -m * xOff - b) & 

(yOff < h) & (yOff > -h))[0] 

return inside 

 

 

def polygonCoords(nside, radius, rotationAngle): 

""" 

Find the x,y coords of a polygon. 

 

This is useful for plotting dither points and showing they lie within 

a given shape. 

 

Parameters 

---------- 

nside : int 

The number of sides of the polygon 

radius : float 

The radius within which to plot the polygon 

rotationAngle : float 

The angle to rotate the polygon to. 

 

Returns 

------- 

[float, float] 

List of x/y coordinates of the points describing the polygon. 

""" 

eachAngle = 2 * np.pi / float(nside) 

xCoords = np.zeros(nside, float) 

yCoords = np.zeros(nside, float) 

for i in range(0, nside): 

xCoords[i] = np.sin(eachAngle * i + rotationAngle) * radius 

yCoords[i] = np.cos(eachAngle * i + rotationAngle) * radius 

return list(zip(xCoords, yCoords)) 

 

 

class RandomDitherFieldPerVisitStacker(BaseStacker): 

""" 

Randomly dither the RA and Dec pointings up to maxDither degrees from center, 

with a different offset for each field, for each visit. 

 

Parameters 

---------- 

raCol : str, optional 

The name of the RA column in the data. 

Default 'fieldRA'. 

decCol : str, optional 

The name of the Dec column in the data. 

Default 'fieldDec'. 

degrees : bool, optional 

Flag whether RA/Dec should be treated as (and kept as) degrees. 

maxDither : float, optional 

The radius of the maximum dither offset, in degrees. 

Default 1.75 degrees. 

inHex : bool, optional 

If True, offsets are constrained to lie within a hexagon inscribed within the maxDither circle. 

If False, offsets can lie anywhere out to the edges of the maxDither circle. 

Default True. 

randomSeed : int, optional 

If set, then used as the random seed for the numpy random number generation for the dither offsets. 

Default None. 

""" 

def __init__(self, raCol='fieldRA', decCol='fieldDec', degrees=True, maxDither=1.75, 

inHex=True, randomSeed=None): 

""" 

@ MaxDither in degrees 

""" 

# Instantiate the RandomDither object and set internal variables. 

self.raCol = raCol 

self.decCol = decCol 

self.degrees = degrees 

# Convert maxDither to radians for internal use. 

self.maxDither = np.radians(maxDither) 

self.inHex = inHex 

self.randomSeed = randomSeed 

# self.units used for plot labels 

175 ↛ 178line 175 didn't jump to line 178, because the condition on line 175 was never false if self.degrees: 

self.units = ['deg', 'deg'] 

else: 

self.units = ['rad', 'rad'] 

# Values required for framework operation: this specifies the names of the new columns. 

self.colsAdded = ['randomDitherFieldPerVisitRa', 'randomDitherFieldPerVisitDec'] 

# Values required for framework operation: this specifies the data columns required from the database. 

self.colsReq = [self.raCol, self.decCol] 

 

def _generateRandomOffsets(self, noffsets): 

xOut = np.array([], float) 

yOut = np.array([], float) 

maxTries = 100 

tries = 0 

while (len(xOut) < noffsets) and (tries < maxTries): 

dithersRad = np.sqrt(np.random.rand(noffsets * 2)) * self.maxDither 

dithersTheta = np.random.rand(noffsets * 2) * np.pi * 2.0 

xOff = dithersRad * np.cos(dithersTheta) 

yOff = dithersRad * np.sin(dithersTheta) 

194 ↛ 199line 194 didn't jump to line 199, because the condition on line 194 was never false if self.inHex: 

# Constrain dither offsets to be within hexagon. 

idx = inHexagon(xOff, yOff, self.maxDither) 

xOff = xOff[idx] 

yOff = yOff[idx] 

xOut = np.concatenate([xOut, xOff]) 

yOut = np.concatenate([yOut, yOff]) 

tries += 1 

202 ↛ 203line 202 didn't jump to line 203, because the condition on line 202 was never true if len(xOut) < noffsets: 

raise ValueError('Could not find enough random points within the hexagon in %d tries. ' 

'Try another random seed?' % (maxTries)) 

self.xOff = xOut[0:noffsets] 

self.yOff = yOut[0:noffsets] 

 

def _run(self, simData, cols_present=False): 

209 ↛ 211line 209 didn't jump to line 211, because the condition on line 209 was never true if cols_present: 

# Column already present in data; assume it is correct and does not need recalculating. 

return simData 

# Generate random numbers for dither, using defined seed value if desired. 

213 ↛ 214line 213 didn't jump to line 214, because the condition on line 213 was never true if self.randomSeed is not None: 

np.random.seed(self.randomSeed) 

# Generate the random dither values. 

noffsets = len(simData[self.raCol]) 

self._generateRandomOffsets(noffsets) 

# Add to RA and dec values. 

219 ↛ 223line 219 didn't jump to line 223, because the condition on line 219 was never false if self.degrees: 

ra = np.radians(simData[self.raCol]) 

dec = np.radians(simData[self.decCol]) 

else: 

ra = simData[self.raCol] 

dec = simData[self.decCol] 

simData['randomDitherFieldPerVisitRa'] = (ra + self.xOff / np.cos(dec)) 

simData['randomDitherFieldPerVisitDec'] = dec + self.yOff 

# Wrap back into expected range. 

simData['randomDitherFieldPerVisitRa'], simData['randomDitherFieldPerVisitDec'] = \ 

wrapRADec(simData['randomDitherFieldPerVisitRa'], simData['randomDitherFieldPerVisitDec']) 

# Convert to degrees 

231 ↛ 234line 231 didn't jump to line 234, because the condition on line 231 was never false if self.degrees: 

for col in self.colsAdded: 

simData[col] = np.degrees(simData[col]) 

return simData 

 

 

class RandomDitherFieldPerNightStacker(RandomDitherFieldPerVisitStacker): 

""" 

Randomly dither the RA and Dec pointings up to maxDither degrees from center, 

one dither offset per new night of observation of a field. 

e.g. visits within the same night, to the same field, have the same offset. 

 

Parameters 

---------- 

raCol : str, optional 

The name of the RA column in the data. 

Default 'fieldRA'. 

decCol : str, optional 

The name of the Dec column in the data. 

Default 'fieldDec'. 

degrees : bool, optional 

Flag whether RA/Dec should be treated as (and kept as) degrees. 

fieldIdCol : str, optional 

The name of the fieldId column in the data. 

Used to identify fields which should be identified as the 'same'. 

Default 'fieldId'. 

nightCol : str, optional 

The name of the night column in the data. 

Default 'night'. 

maxDither : float, optional 

The radius of the maximum dither offset, in degrees. 

Default 1.75 degrees. 

inHex : bool, optional 

If True, offsets are constrained to lie within a hexagon inscribed within the maxDither circle. 

If False, offsets can lie anywhere out to the edges of the maxDither circle. 

Default True. 

randomSeed : int, optional 

If set, then used as the random seed for the numpy random number generation for the dither offsets. 

Default None. 

""" 

def __init__(self, raCol='fieldRA', decCol='fieldDec', degrees=True, fieldIdCol='fieldId', 

nightCol='night', maxDither=1.75, inHex=True, randomSeed=None): 

""" 

@ MaxDither in degrees 

""" 

# Instantiate the RandomDither object and set internal variables. 

super(RandomDitherFieldPerNightStacker, self).__init__(raCol=raCol, decCol=decCol, degrees=degrees, 

maxDither=maxDither, inHex=inHex, 

randomSeed=randomSeed) 

self.nightCol = nightCol 

self.fieldIdCol = fieldIdCol 

# Values required for framework operation: this specifies the names of the new columns. 

self.colsAdded = ['randomDitherFieldPerNightRa', 'randomDitherFieldPerNightDec'] 

# Values required for framework operation: this specifies the data columns required from the database. 

self.colsReq = [self.raCol, self.decCol, self.nightCol, self.fieldIdCol] 

 

def _run(self, simData, cols_present=False): 

if cols_present: 

return simData 

# Generate random numbers for dither, using defined seed value if desired. 

if self.randomSeed is not None: 

np.random.seed(self.randomSeed) 

# Generate the random dither values, one per night per field. 

fields = np.unique(simData[self.fieldIdCol]) 

nights = np.unique(simData[self.nightCol]) 

self._generateRandomOffsets(len(fields) * len(nights)) 

if self.degrees: 

ra = np.radians(simData[self.raCol]) 

dec = np.radians(simData[self.decCol]) 

else: 

ra = simData[self.raCol] 

dec = simData[self.decCol] 

# counter to ensure new random numbers are chosen every time 

delta = 0 

for fieldid in np.unique(simData[self.fieldIdCol]): 

# Identify observations of this field. 

match = np.where(simData[self.fieldIdCol] == fieldid)[0] 

# Apply dithers, increasing each night. 

nights = simData[self.nightCol][match] 

vertexIdxs = np.searchsorted(np.unique(nights), nights) 

vertexIdxs = vertexIdxs % len(self.xOff) 

# ensure that the same xOff/yOff entries are not chosen 

delta = delta + len(vertexIdxs) 

simData['randomDitherFieldPerNightRa'][match] = (ra[match] + 

self.xOff[vertexIdxs] / 

np.cos(dec[match])) 

simData['randomDitherFieldPerNightDec'][match] = (dec[match] + 

self.yOff[vertexIdxs]) 

# Wrap into expected range. 

simData['randomDitherFieldPerNightRa'], simData['randomDitherFieldPerNightDec'] = \ 

wrapRADec(simData['randomDitherFieldPerNightRa'], simData['randomDitherFieldPerNightDec']) 

if self.degrees: 

for col in self.colsAdded: 

simData[col] = np.degrees(simData[col]) 

return simData 

 

 

class RandomDitherPerNightStacker(RandomDitherFieldPerVisitStacker): 

""" 

Randomly dither the RA and Dec pointings up to maxDither degrees from center, 

one dither offset per night. 

All fields observed within the same night get the same offset. 

 

Parameters 

---------- 

raCol : str, optional 

The name of the RA column in the data. 

Default 'fieldRA'. 

decCol : str, optional 

The name of the Dec column in the data. 

Default 'fieldDec'. 

degrees : bool, optional 

Flag whether RA/Dec should be treated as (and kept as) degrees. 

nightCol : str, optional 

The name of the night column in the data. 

Default 'night'. 

maxDither : float, optional 

The radius of the maximum dither offset, in degrees. 

Default 1.75 degrees. 

inHex : bool, optional 

If True, offsets are constrained to lie within a hexagon inscribed within the maxDither circle. 

If False, offsets can lie anywhere out to the edges of the maxDither circle. 

Default True. 

randomSeed : int, optional 

If set, then used as the random seed for the numpy random number generation for the dither offsets. 

Default None. 

""" 

def __init__(self, raCol='fieldRA', decCol='fieldDec', degrees=True, nightCol='night', 

maxDither=1.75, inHex=True, randomSeed=None): 

""" 

@ MaxDither in degrees 

""" 

# Instantiate the RandomDither object and set internal variables. 

super(RandomDitherPerNightStacker, self).__init__(raCol=raCol, decCol=decCol, degrees=degrees, 

maxDither=maxDither, inHex=inHex, 

randomSeed=randomSeed) 

self.nightCol = nightCol 

# Values required for framework operation: this specifies the names of the new columns. 

self.colsAdded = ['randomDitherPerNightRa', 'randomDitherPerNightDec'] 

# Values required for framework operation: this specifies the data columns required from the database. 

self.colsReq = [self.raCol, self.decCol, self.nightCol] 

 

def _run(self, simData, cols_present=False): 

374 ↛ 375line 374 didn't jump to line 375, because the condition on line 374 was never true if cols_present: 

return simData 

# Generate random numbers for dither, using defined seed value if desired. 

377 ↛ 378line 377 didn't jump to line 378, because the condition on line 377 was never true if self.randomSeed is not None: 

np.random.seed(self.randomSeed) 

# Generate the random dither values, one per night. 

nights = np.unique(simData[self.nightCol]) 

self._generateRandomOffsets(len(nights)) 

382 ↛ 386line 382 didn't jump to line 386, because the condition on line 382 was never false if self.degrees: 

ra = np.radians(simData[self.raCol]) 

dec = np.radians(simData[self.decCol]) 

else: 

ra = simData[self.raCol] 

dec = simData[self.decCol] 

# Add to RA and dec values. 

for n, x, y in zip(nights, self.xOff, self.yOff): 

match = np.where(simData[self.nightCol] == n)[0] 

simData['randomDitherPerNightRa'][match] = (ra[match] + 

x / np.cos(dec[match])) 

simData['randomDitherPerNightDec'][match] = dec[match] + y 

# Wrap RA/Dec into expected range. 

simData['randomDitherPerNightRa'], simData['randomDitherPerNightDec'] = \ 

wrapRADec(simData['randomDitherPerNightRa'], simData['randomDitherPerNightDec']) 

397 ↛ 400line 397 didn't jump to line 400, because the condition on line 397 was never false if self.degrees: 

for col in self.colsAdded: 

simData[col] = np.degrees(simData[col]) 

return simData 

 

 

class SpiralDitherFieldPerVisitStacker(BaseStacker): 

""" 

Offset along an equidistant spiral with numPoints, out to a maximum radius of maxDither. 

Each visit to a field receives a new, sequential offset. 

 

Parameters 

---------- 

raCol : str, optional 

The name of the RA column in the data. 

Default 'fieldRA'. 

decCol : str, optional 

The name of the Dec column in the data. 

Default 'fieldDec'. 

degrees : bool, optional 

Flag whether RA/Dec should be treated as (and kept as) degrees. 

fieldIdCol : str, optional 

The name of the fieldId column in the data. 

Used to identify fields which should be identified as the 'same'. 

Default 'fieldId'. 

numPoints : int, optional 

The number of points in the spiral. 

Default 60. 

maxDither : float, optional 

The radius of the maximum dither offset, in degrees. 

Default 1.75 degrees. 

nCoils : int, optional 

The number of coils the spiral should have. 

Default 5. 

inHex : bool, optional 

If True, offsets are constrained to lie within a hexagon inscribed within the maxDither circle. 

If False, offsets can lie anywhere out to the edges of the maxDither circle. 

Default True. 

""" 

def __init__(self, raCol='fieldRA', decCol='fieldDec', degrees=True, fieldIdCol='fieldId', 

numPoints=60, maxDither=1.75, nCoils=5, inHex=True): 

""" 

@ MaxDither in degrees 

""" 

self.raCol = raCol 

self.decCol = decCol 

self.degrees = degrees 

self.fieldIdCol = fieldIdCol 

# Convert maxDither from degrees (internal units for ra/dec are radians) 

self.numPoints = numPoints 

self.nCoils = nCoils 

self.maxDither = np.radians(maxDither) 

self.inHex = inHex 

# self.units used for plot labels 

451 ↛ 454line 451 didn't jump to line 454, because the condition on line 451 was never false if self.degrees: 

self.units = ['deg', 'deg'] 

else: 

self.units = ['rad', 'rad'] 

# Values required for framework operation: this specifies the names of the new columns. 

self.colsAdded = ['spiralDitherFieldPerVisitRa', 'spiralDitherFieldPerVisitDec'] 

# Values required for framework operation: this specifies the data columns required from the database. 

self.colsReq = [self.raCol, self.decCol, self.fieldIdCol] 

 

def _generateSpiralOffsets(self): 

# First generate a full archimedean spiral .. 

theta = np.arange(0.0001, self.nCoils * np.pi * 2., 0.001) 

a = self.maxDither/theta.max() 

464 ↛ 466line 464 didn't jump to line 466, because the condition on line 464 was never false if self.inHex: 

a = 0.85 * a 

r = theta * a 

# Then pick out equidistant points along the spiral. 

arc = a / 2.0 * (theta * np.sqrt(1 + theta**2) + np.log(theta + np.sqrt(1 + theta**2))) 

stepsize = arc.max()/float(self.numPoints) 

arcpts = np.arange(0, arc.max(), stepsize) 

arcpts = arcpts[0:self.numPoints] 

rpts = np.zeros(self.numPoints, float) 

thetapts = np.zeros(self.numPoints, float) 

for i, ap in enumerate(arcpts): 

diff = np.abs(arc - ap) 

match = np.where(diff == diff.min())[0] 

rpts[i] = r[match] 

thetapts[i] = theta[match] 

# Translate these r/theta points into x/y (ra/dec) offsets. 

self.xOff = rpts * np.cos(thetapts) 

self.yOff = rpts * np.sin(thetapts) 

 

def _run(self, simData, cols_present=False): 

if cols_present: 

return simData 

# Generate the spiral offset vertices. 

self._generateSpiralOffsets() 

# Now apply to observations. 

if self.degrees: 

ra = np.radians(simData[self.raCol]) 

dec = np.radians(simData[self.decCol]) 

else: 

ra = simData[self.raCol] 

dec = simData[self.decCol] 

for fieldid in np.unique(simData[self.fieldIdCol]): 

match = np.where(simData[self.fieldIdCol] == fieldid)[0] 

# Apply sequential dithers, increasing with each visit. 

vertexIdxs = np.arange(0, len(match), 1) 

vertexIdxs = vertexIdxs % self.numPoints 

simData['spiralDitherFieldPerVisitRa'][match] = (ra[match] + 

self.xOff[vertexIdxs] / 

np.cos(dec[match])) 

simData['spiralDitherFieldPerVisitDec'][match] = (dec[match] + 

self.yOff[vertexIdxs]) 

# Wrap into expected range. 

simData['spiralDitherFieldPerVisitRa'], simData['spiralDitherFieldPerVisitDec'] = \ 

wrapRADec(simData['spiralDitherFieldPerVisitRa'], simData['spiralDitherFieldPerVisitDec']) 

if self.degrees: 

for col in self.colsAdded: 

simData[col] = np.degrees(simData[col]) 

return simData 

 

 

class SpiralDitherFieldPerNightStacker(SpiralDitherFieldPerVisitStacker): 

""" 

Offset along an equidistant spiral with numPoints, out to a maximum radius of maxDither. 

Each field steps along a sequential series of offsets, each night it is observed. 

 

Parameters 

---------- 

raCol : str, optional 

The name of the RA column in the data. 

Default 'fieldRA'. 

decCol : str, optional 

The name of the Dec column in the data. 

Default 'fieldDec'. 

degrees : bool, optional 

Flag whether RA/Dec should be treated as (and kept as) degrees. 

fieldIdCol : str, optional 

The name of the fieldId column in the data. 

Used to identify fields which should be identified as the 'same'. 

Default 'fieldId'. 

nightCol : str, optional 

The name of the night column in the data. 

Default 'night'. 

numPoints : int, optional 

The number of points in the spiral. 

Default 60. 

maxDither : float, optional 

The radius of the maximum dither offset, in degrees. 

Default 1.75 degrees. 

nCoils : int, optional 

The number of coils the spiral should have. 

Default 5. 

inHex : bool, optional 

If True, offsets are constrained to lie within a hexagon inscribed within the maxDither circle. 

If False, offsets can lie anywhere out to the edges of the maxDither circle. 

Default True. 

""" 

def __init__(self, raCol='fieldRA', decCol='fieldDec', degrees=True, fieldIdCol='fieldId', 

nightCol='night', numPoints=60, maxDither=1.75, nCoils=5, inHex=True): 

""" 

@ MaxDither in degrees 

""" 

super(SpiralDitherFieldPerNightStacker, self).__init__(raCol=raCol, decCol=decCol, degrees=degrees, 

fieldIdCol=fieldIdCol, 

numPoints=numPoints, maxDither=maxDither, 

nCoils=nCoils, inHex=inHex) 

self.nightCol = nightCol 

# Values required for framework operation: this specifies the names of the new columns. 

self.colsAdded = ['spiralDitherFieldPerNightRa', 'spiralDitherFieldPerNightDec'] 

# Values required for framework operation: this specifies the data columns required from the database. 

self.colsReq.append(self.nightCol) 

 

def _run(self, simData, cols_present=False): 

if cols_present: 

return simData 

self._generateSpiralOffsets() 

if self.degrees: 

ra = np.radians(simData[self.raCol]) 

dec = np.radians(simData[self.decCol]) 

else: 

ra = simData[self.raCol] 

dec = simData[self.decCol] 

for fieldid in np.unique(simData[self.fieldIdCol]): 

# Identify observations of this field. 

match = np.where(simData[self.fieldIdCol] == fieldid)[0] 

# Apply a sequential dither, increasing each night. 

nights = simData[self.nightCol][match] 

vertexIdxs = np.searchsorted(np.unique(nights), nights) 

vertexIdxs = vertexIdxs % self.numPoints 

simData['spiralDitherFieldPerNightRa'][match] = (ra[match] + 

self.xOff[vertexIdxs] / 

np.cos(dec[match])) 

simData['spiralDitherFieldPerNightDec'][match] = (dec[match] + 

self.yOff[vertexIdxs]) 

# Wrap into expected range. 

simData['spiralDitherFieldPerNightRa'], simData['spiralDitherFieldPerNightDec'] = \ 

wrapRADec(simData['spiralDitherFieldPerNightRa'], simData['spiralDitherFieldPerNightDec']) 

if self.degrees: 

for col in self.colsAdded: 

simData[col] = np.degrees(simData[col]) 

return simData 

 

 

class SpiralDitherPerNightStacker(SpiralDitherFieldPerVisitStacker): 

""" 

Offset along an equidistant spiral with numPoints, out to a maximum radius of maxDither. 

All fields observed in the same night receive the same sequential offset, changing per night. 

 

Parameters 

---------- 

raCol : str, optional 

The name of the RA column in the data. 

Default 'fieldRA'. 

decCol : str, optional 

The name of the Dec column in the data. 

Default 'fieldDec'. 

degrees : bool, optional 

Flag whether RA/Dec should be treated as (and kept as) degrees. 

fieldIdCol : str, optional 

The name of the fieldId column in the data. 

Used to identify fields which should be identified as the 'same'. 

Default 'fieldId'. 

nightCol : str, optional 

The name of the night column in the data. 

Default 'night'. 

numPoints : int, optional 

The number of points in the spiral. 

Default 60. 

maxDither : float, optional 

The radius of the maximum dither offset, in degrees. 

Default 1.75 degrees. 

nCoils : int, optional 

The number of coils the spiral should have. 

Default 5. 

inHex : bool, optional 

If True, offsets are constrained to lie within a hexagon inscribed within the maxDither circle. 

If False, offsets can lie anywhere out to the edges of the maxDither circle. 

Default True. 

""" 

def __init__(self, raCol='fieldRA', decCol='fieldDec', degrees=True, fieldIdCol='fieldId', 

nightCol='night', numPoints=60, maxDither=1.75, nCoils=5, inHex=True): 

""" 

@ MaxDither in degrees 

""" 

super(SpiralDitherPerNightStacker, self).__init__(raCol=raCol, decCol=decCol, degrees=degrees, 

fieldIdCol=fieldIdCol, 

numPoints=numPoints, maxDither=maxDither, 

nCoils=nCoils, inHex=inHex) 

self.nightCol = nightCol 

# Values required for framework operation: this specifies the names of the new columns. 

self.colsAdded = ['spiralDitherPerNightRa', 'spiralDitherPerNightDec'] 

# Values required for framework operation: this specifies the data columns required from the database. 

self.colsReq.append(self.nightCol) 

 

def _run(self, simData, cols_present=False): 

648 ↛ 649line 648 didn't jump to line 649, because the condition on line 648 was never true if cols_present: 

return simData 

self._generateSpiralOffsets() 

nights = np.unique(simData[self.nightCol]) 

652 ↛ 656line 652 didn't jump to line 656, because the condition on line 652 was never false if self.degrees: 

ra = np.radians(simData[self.raCol]) 

dec = np.radians(simData[self.decCol]) 

else: 

ra = simData[self.raCol] 

dec = simData[self.decCol] 

# Add to RA and dec values. 

vertexIdxs = np.searchsorted(nights, simData[self.nightCol]) 

vertexIdxs = vertexIdxs % self.numPoints 

simData['spiralDitherPerNightRa'] = (ra + 

self.xOff[vertexIdxs] / np.cos(dec)) 

simData['spiralDitherPerNightDec'] = dec + self.yOff[vertexIdxs] 

# Wrap RA/Dec into expected range. 

simData['spiralDitherPerNightRa'], simData['spiralDitherPerNightDec'] = \ 

wrapRADec(simData['spiralDitherPerNightRa'], simData['spiralDitherPerNightDec']) 

667 ↛ 670line 667 didn't jump to line 670, because the condition on line 667 was never false if self.degrees: 

for col in self.colsAdded: 

simData[col] = np.degrees(simData[col]) 

return simData 

 

 

class HexDitherFieldPerVisitStacker(BaseStacker): 

""" 

Use offsets from the hexagonal grid of 'hexdither', but visit each vertex sequentially. 

Sequential offset for each visit. 

 

Parameters 

---------- 

raCol : str, optional 

The name of the RA column in the data. 

Default 'fieldRA'. 

decCol : str, optional 

The name of the Dec column in the data. 

Default 'fieldDec'. 

degrees : bool, optional 

Flag whether RA/Dec should be treated as (and kept as) degrees. 

fieldIdCol : str, optional 

The name of the fieldId column in the data. 

Used to identify fields which should be identified as the 'same'. 

Default 'fieldId'. 

maxDither : float, optional 

The radius of the maximum dither offset, in degrees. 

Default 1.75 degrees. 

inHex : bool, optional 

If True, offsets are constrained to lie within a hexagon inscribed within the maxDither circle. 

If False, offsets can lie anywhere out to the edges of the maxDither circle. 

Default True. 

""" 

def __init__(self, raCol='fieldRA', decCol='fieldDec', degrees=True, 

fieldIdCol='fieldId', maxDither=1.75, inHex=True): 

""" 

@ MaxDither in degrees 

""" 

self.raCol = raCol 

self.decCol = decCol 

self.degrees = degrees 

self.fieldIdCol = fieldIdCol 

self.maxDither = np.radians(maxDither) 

self.inHex = inHex 

# self.units used for plot labels 

712 ↛ 715line 712 didn't jump to line 715, because the condition on line 712 was never false if self.degrees: 

self.units = ['deg', 'deg'] 

else: 

self.units = ['rad', 'rad'] 

# Values required for framework operation: this specifies the names of the new columns. 

self.colsAdded = ['hexDitherFieldPerVisitRa', 'hexDitherFieldPerVisitDec'] 

# Values required for framework operation: this specifies the data columns required from the database. 

self.colsReq = [self.raCol, self.decCol, self.fieldIdCol] 

 

def _generateHexOffsets(self): 

# Set up basics of dither pattern. 

dith_level = 4 

nrows = 2**dith_level 

halfrows = int(nrows / 2.) 

# Calculate size of each offset 

dith_size_x = self.maxDither * 2.0 / float(nrows) 

dith_size_y = np.sqrt(3) * self.maxDither / float(nrows) # sqrt 3 comes from hexagon 

729 ↛ 733line 729 didn't jump to line 733, because the condition on line 729 was never false if self.inHex: 

dith_size_x = 0.95 * dith_size_x 

dith_size_y = 0.95 * dith_size_y 

# Calculate the row identification number, going from 0 at center 

nid_row = np.arange(-halfrows, halfrows + 1, 1) 

# and calculate the number of vertices in each row. 

vert_in_row = np.arange(-halfrows, halfrows + 1, 1) 

# First calculate how many vertices we will create in each row. 

total_vert = 0 

for i in range(-halfrows, halfrows + 1, 1): 

vert_in_row[i] = (nrows+1) - abs(nid_row[i]) 

total_vert += vert_in_row[i] 

self.numPoints = total_vert 

self.xOff = [] 

self.yOff = [] 

# Calculate offsets over hexagonal grid. 

for i in range(0, nrows+1, 1): 

for j in range(0, vert_in_row[i], 1): 

self.xOff.append(dith_size_x * (j - (vert_in_row[i] - 1) / 2.0)) 

self.yOff.append(dith_size_y * nid_row[i]) 

self.xOff = np.array(self.xOff) 

self.yOff = np.array(self.yOff) 

 

def _run(self, simData, cols_present=False): 

if cols_present: 

return simData 

self._generateHexOffsets() 

if self.degrees: 

ra = np.radians(simData[self.raCol]) 

dec = np.radians(simData[self.decCol]) 

else: 

ra = simData[self.raCol] 

dec = simData[self.decCol] 

for fieldid in np.unique(simData[self.fieldIdCol]): 

# Identify observations of this field. 

match = np.where(simData[self.fieldIdCol] == fieldid)[0] 

# Apply sequential dithers, increasing with each visit. 

vertexIdxs = np.arange(0, len(match), 1) 

vertexIdxs = vertexIdxs % self.numPoints 

simData['hexDitherFieldPerVisitRa'][match] = (ra[match] + 

self.xOff[vertexIdxs] / 

np.cos(dec[match])) 

simData['hexDitherFieldPerVisitDec'][match] = dec[match] + self.yOff[vertexIdxs] 

# Wrap into expected range. 

simData['hexDitherFieldPerVisitRa'], simData['hexDitherFieldPerVisitDec'] = \ 

wrapRADec(simData['hexDitherFieldPerVisitRa'], simData['hexDitherFieldPerVisitDec']) 

if self.degrees: 

for col in self.colsAdded: 

simData[col] = np.degrees(simData[col]) 

return simData 

 

 

class HexDitherFieldPerNightStacker(HexDitherFieldPerVisitStacker): 

""" 

Use offsets from the hexagonal grid of 'hexdither', but visit each vertex sequentially. 

Sequential offset for each night of visits. 

 

Parameters 

---------- 

raCol : str, optional 

The name of the RA column in the data. 

Default 'fieldRA'. 

decCol : str, optional 

The name of the Dec column in the data. 

Default 'fieldDec'. 

degrees : bool, optional 

Flag whether RA/Dec should be treated as (and kept as) degrees. 

fieldIdCol : str, optional 

The name of the fieldId column in the data. 

Used to identify fields which should be identified as the 'same'. 

Default 'fieldId'. 

nightCol : str, optional 

The name of the night column in the data. 

Default 'night'. 

maxDither : float, optional 

The radius of the maximum dither offset, in degrees. 

Default 1.75 degrees. 

inHex : bool, optional 

If True, offsets are constrained to lie within a hexagon inscribed within the maxDither circle. 

If False, offsets can lie anywhere out to the edges of the maxDither circle. 

Default True. 

""" 

def __init__(self, raCol='fieldRA', decCol='fieldDec', degrees=True, 

fieldIdCol='fieldId', nightCol='night', 

maxDither=1.75, inHex=True): 

""" 

@ MaxDither in degrees 

""" 

super(HexDitherFieldPerNightStacker, self).__init__(raCol=raCol, decCol=decCol, fieldIdCol=fieldIdCol, 

degrees=degrees, maxDither=maxDither, inHex=inHex) 

self.nightCol = nightCol 

# Values required for framework operation: this specifies the names of the new columns. 

self.colsAdded = ['hexDitherFieldPerNightRa', 'hexDitherFieldPerNightDec'] 

# Values required for framework operation: this specifies the data columns required from the database. 

self.colsReq.append(self.nightCol) 

 

def _run(self, simData, cols_present=False): 

if cols_present: 

return simData 

self._generateHexOffsets() 

if self.degrees: 

ra = np.radians(simData[self.raCol]) 

dec = np.radians(simData[self.decCol]) 

else: 

ra = simData[self.raCol] 

dec = simData[self.decCol] 

for fieldid in np.unique(simData[self.fieldIdCol]): 

# Identify observations of this field. 

match = np.where(simData[self.fieldIdCol] == fieldid)[0] 

# Apply a sequential dither, increasing each night. 

vertexIdxs = np.arange(0, len(match), 1) 

nights = simData[self.nightCol][match] 

vertexIdxs = np.searchsorted(np.unique(nights), nights) 

vertexIdxs = vertexIdxs % self.numPoints 

simData['hexDitherFieldPerNightRa'][match] = (ra[match] + 

self.xOff[vertexIdxs] / 

np.cos(dec[match])) 

simData['hexDitherFieldPerNightDec'][match] = (dec[match] + 

self.yOff[vertexIdxs]) 

# Wrap into expected range. 

simData['hexDitherFieldPerNightRa'], simData['hexDitherFieldPerNightDec'] = \ 

wrapRADec(simData['hexDitherFieldPerNightRa'], simData['hexDitherFieldPerNightDec']) 

if self.degrees: 

for col in self.colsAdded: 

simData[col] = np.degrees(simData[col]) 

return simData 

 

 

class HexDitherPerNightStacker(HexDitherFieldPerVisitStacker): 

""" 

Use offsets from the hexagonal grid of 'hexdither', but visit each vertex sequentially. 

Sequential offset per night for all fields. 

 

Parameters 

---------- 

raCol : str, optional 

The name of the RA column in the data. 

Default 'fieldRA'. 

decCol : str, optional 

The name of the Dec column in the data. 

Default 'fieldDec'. 

degrees : bool, optional 

Flag whether RA/Dec should be treated as (and kept as) degrees. 

fieldIdCol : str, optional 

The name of the fieldId column in the data. 

Used to identify fields which should be identified as the 'same'. 

Default 'fieldId'. 

nightCol : str, optional 

The name of the night column in the data. 

Default 'night'. 

maxDither : float, optional 

The radius of the maximum dither offset, in degrees. 

Default 1.75 degrees. 

inHex : bool, optional 

If True, offsets are constrained to lie within a hexagon inscribed within the maxDither circle. 

If False, offsets can lie anywhere out to the edges of the maxDither circle. 

Default True. 

""" 

def __init__(self, raCol='fieldRA', decCol='fieldDec', degrees=True, fieldIdCol='fieldId', 

nightCol='night', maxDither=1.75, inHex=True): 

""" 

@ MaxDither in degrees 

""" 

super(HexDitherPerNightStacker, self).__init__(raCol=raCol, decCol=decCol, degrees=degrees, 

fieldIdCol=fieldIdCol, 

maxDither=maxDither, inHex=inHex) 

self.nightCol = nightCol 

# Values required for framework operation: this specifies the data columns required from the database. 

self.colsReq.append(self.nightCol) 

self.addedRA = 'hexDitherPerNightRa' 

self.addedDec = 'hexDitherPerNightDec' 

# Values required for framework operation: this specifies the names of the new columns. 

self.colsAdded = [self.addedRA, self.addedDec] 

 

def _run(self, simData, cols_present=False): 

904 ↛ 905line 904 didn't jump to line 905, because the condition on line 904 was never true if cols_present: 

return simData 

# Generate the spiral dither values 

self._generateHexOffsets() 

nights = np.unique(simData[self.nightCol]) 

909 ↛ 913line 909 didn't jump to line 913, because the condition on line 909 was never false if self.degrees: 

ra = np.radians(simData[self.raCol]) 

dec = np.radians(simData[self.decCol]) 

else: 

ra = simData[self.raCol] 

dec = simData[self.decCol] 

# Add to RA and dec values. 

vertexID = 0 

for n in nights: 

match = np.where(simData[self.nightCol] == n)[0] 

vertexID = vertexID % self.numPoints 

simData[self.addedRA][match] = (ra[match] + self.xOff[vertexID] / np.cos(dec[match])) 

simData[self.addedDec][match] = dec[match] + self.yOff[vertexID] 

vertexID += 1 

# Wrap RA/Dec into expected range. 

simData[self.addedRA], simData[self.addedDec] = \ 

wrapRADec(simData[self.addedRA], simData[self.addedDec]) 

926 ↛ 929line 926 didn't jump to line 929, because the condition on line 926 was never false if self.degrees: 

for col in self.colsAdded: 

simData[col] = np.degrees(simData[col]) 

return simData 

 

 

class DefaultDitherStacker(HexDitherPerNightStacker): 

""" 

Make a default dither pattern to stack on ditheredRA and ditheredDec. 

The default pattern is HexDitherPerNightStacker. 

 

Parameters 

---------- 

raCol : str, optional 

The name of the RA column in the data. 

Default 'fieldRA'. 

decCol : str, optional 

The name of the Dec column in the data. 

Default 'fieldDec'. 

degrees : bool, optional 

Flag whether RA/Dec should be treated as (and kept as) degrees. 

fieldIdCol : str, optional 

The name of the fieldId column in the data. 

Used to identify fields which should be identified as the 'same'. 

Default 'fieldId'. 

nightCol : str, optional 

The name of the night column in the data. 

Default 'night'. 

maxDither : float, optional 

The radius of the maximum dither offset, in degrees. 

Default 1.75 degrees. 

inHex : bool, optional 

If True, offsets are constrained to lie within a hexagon inscribed within the maxDither circle. 

If False, offsets can lie anywhere out to the edges of the maxDither circle. 

Default True. 

""" 

def __init__(self, raCol='fieldRA', decCol='fieldDec', degrees=True, fieldIdCol='fieldId', 

nightCol='night', maxDither=1.75, inHex=True): 

super(DefaultDitherStacker, self).__init__(raCol=raCol, decCol=decCol, degrees=degrees, 

fieldIdCol=fieldIdCol, nightCol=nightCol, 

maxDither=maxDither, inHex=inHex) 

self.addedRA = 'ditheredRA' 

self.addedDec = 'ditheredDec' 

# Values required for framework operation: this specifies the names of the new columns. 

self.colsAdded = [self.addedRA, self.addedDec] 

 

 

class RandomRotDitherPerFilterChangeStacker(BaseStacker): 

""" 

Randomly dither the physical angle of the telescope rotator wrt the mount, 

after every filter change. 

 

Parameters 

---------- 

rotTelCol : str, optional 

The name of the column in the data specifying the physical angle 

of the telescope rotator wrt. the mount. 

Default: 'rotTelPos'. 

filterCol : str, optional 

The name of the filter column in the data. 

Default: 'filter'. 

degrees : boolean, optional 

True if angles in the database are in degrees (default). 

If True, returned dithered values are in degrees also. 

If False, angles assumed to be in radians and returned in radians. 

maxDither : float, optional 

Abs(maximum) rotational dither, in degrees. The dithers then will be 

between -maxDither to maxDither. 

Default: 90 degrees. 

maxRotAngle : float, optional 

Maximum rotator angle possible for the camera. Default 90 degrees. 

minRotAngle : float, optional 

Minimum rotator angle possible for the camera. Default -90 degrees. 

randomSeed: int, optional 

If set, then used as the random seed for the numpy random number 

generation for the dither offsets. 

Default: None. 

""" 

def __init__(self, rotTelCol= 'rotTelPos', filterCol= 'filter', degrees=True, 

maxDither= 90., maxRotAngle=90, minRotAngle=-90, randomSeed=None): 

""" 

@ MaxDither in degrees. 

""" 

# Instantiate the RandomDither object and set internal variables. 

self.rotTelCol = rotTelCol 

self.filterCol = filterCol 

self.degrees = degrees 

self.maxDither = maxDither 

self.maxRotAngle = maxRotAngle 

self.minRotAngle = minRotAngle 

self.randomSeed = randomSeed 

# self.units used for plot labels 

1018 ↛ 1021line 1018 didn't jump to line 1021, because the condition on line 1018 was never false if self.degrees: 

self.units = ['deg'] 

else: 

self.units = ['rad'] 

# Values required for framework operation: this specifies the names of the new columns. 

self.colsAdded = ['randomDitherPerFilterChangeRotTelPos'] 

# Values required for framework operation: this specifies the data columns required from the database. 

self.colsReq = [self.rotTelCol, self.filterCol] 

 

def _run(self, simData, cols_present=False): 

# Just go ahead and return if the columns were already in place. 

1029 ↛ 1030line 1029 didn't jump to line 1030, because the condition on line 1029 was never true if cols_present: 

return simData 

# Generate random numbers for dither, using defined seed value if desired. 

1032 ↛ 1036line 1032 didn't jump to line 1036, because the condition on line 1032 was never false if self.randomSeed is not None: 

np.random.seed(self.randomSeed) 

 

# Identify points where the filter changes. 

changeIdxs = np.where(simData[self.filterCol][1:] != simData[self.filterCol][:-1])[0] 

 

1038 ↛ 1039line 1038 didn't jump to line 1039, because the condition on line 1038 was never true if len(changeIdxs) == 0: 

rotOffset = 0 

 

else: 

# Calculate random offsets between +/- self.maxDither -- in degrees. 

randomOffsets = np.random.rand(len(changeIdxs)) * 2.0 * self.maxDither - self.maxDither 

 

rotOffset = np.zeros(len(simData), float) 

for i, (c, cn) in enumerate(zip(changeIdxs, changeIdxs[1:])): 

rotOffset[c+1:cn+1] = randomOffsets[i] 

rotOffset[changeIdxs[-1]+1:] = randomOffsets[-1] 

 

# Add the random offsets to the RotTelPos values and convert to radians if required. 

1051 ↛ 1052line 1051 didn't jump to line 1052, because the condition on line 1051 was never true if not self.degrees: 

rotOffset = np.radians(rotOffset) 

rotDither = 'randomDitherPerFilterChangeRotTelPos' 

simData[rotDither] = simData[self.rotTelCol] + rotOffset 

 

# BUT the camera rotator cannot go further than +/- 90 degrees. 

# Without a better alternative, let's just cut off any values which exceed this range. 

maxRotTelPos = self.maxRotAngle 

minRotTelPos = self.minRotAngle 

1060 ↛ 1061line 1060 didn't jump to line 1061, because the condition on line 1060 was never true if not self.degrees: 

maxRotTelPos = np.radians(maxRotTelPos) 

minRotTelPos = np.radians(minRotTelPos) 

simData[rotDither] = np.where(simData[rotDither] > maxRotTelPos, maxRotTelPos, simData[rotDither]) 

simData[rotDither] = np.where(simData[rotDither] < minRotTelPos, minRotTelPos, simData[rotDither]) 

return simData