|
| 1 | +/*****************************************************************************************************************/ |
| 2 | + |
| 3 | +// @author Michael Roberts <[email protected]> |
| 4 | +// @package @observerly/astrometry/observer |
| 5 | +// @license Copyright © 2021-2024 observerly |
| 6 | + |
| 7 | +/*****************************************************************************************************************/ |
| 8 | + |
| 9 | +import { describe, expect, it } from 'vitest' |
| 10 | + |
| 11 | +import { getFieldOfView } from '../src' |
| 12 | + |
| 13 | +/*****************************************************************************************************************/ |
| 14 | + |
| 15 | +// For testing we will fix the aperture to be 0.08m (80mm): |
| 16 | +export const apertureWidth = 0.08 |
| 17 | + |
| 18 | +// For testing we will fix the focal length to be 0.6m (600mm): |
| 19 | +export const focalLength = 0.6 |
| 20 | + |
| 21 | +// For testing we will fix the pixel size to be 6.45μm: |
| 22 | +export const pixelSize = 6.45e-6 |
| 23 | + |
| 24 | +/*****************************************************************************************************************/ |
| 25 | + |
| 26 | +describe('getFieldOfView', () => { |
| 27 | + it('should be defined', () => { |
| 28 | + expect(getFieldOfView).toBeDefined |
| 29 | + }) |
| 30 | + |
| 31 | + it('should return the correct value for a 600mm focal length', () => { |
| 32 | + const fov = getFieldOfView(focalLength, pixelSize, { x: 1392, y: 1040 }) |
| 33 | + // 0.86° x 0.64° field of view: |
| 34 | + expect(fov.x).toBe(0.857374044633764) |
| 35 | + expect(fov.y).toBe(0.6405668149562604) |
| 36 | + }) |
| 37 | + |
| 38 | + it('should return the correct value for a 1000mm focal length', () => { |
| 39 | + const fov = getFieldOfView(1.0, pixelSize, { x: 1392, y: 1040 }) |
| 40 | + // 0.51° x 0.38° field of view: |
| 41 | + expect(fov.x).toBe(0.5144244267802583) |
| 42 | + expect(fov.y).toBe(0.3843400889737562) |
| 43 | + }) |
| 44 | + |
| 45 | + it('should return the correct value for a 600mm focal length and a 8.25μm pixel size', () => { |
| 46 | + const fov = getFieldOfView(focalLength, 8.25e-6, { x: 1392, y: 1040 }) |
| 47 | + // 1.1° x 0.82° field of view: |
| 48 | + expect(fov.x).toBe(1.0966412198803959) |
| 49 | + expect(fov.y).toBe(0.8193296470370773) |
| 50 | + }) |
| 51 | +}) |
| 52 | + |
| 53 | +/*****************************************************************************************************************/ |
0 commit comments