Skip to content

Commit

Permalink
allow iers degraded accuracy
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagohm committed Dec 22, 2024
1 parent 3715440 commit 2170848
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 12 deletions.
1 change: 1 addition & 0 deletions scripts/astropy/iers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# https://docs.astropy.org/en/stable/api/astropy.utils.iers.IERS.html

iers.conf.auto_download = False
iers.conf.iers_degraded_accuracy = 'warn'

t = Time('2020-10-07T12:34:56', format='isot', scale='utc')

Expand Down
20 changes: 18 additions & 2 deletions src/iers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,30 @@ import { Timescale, timeYMDHMS } from './time'

test('iersA', async () => {
await iersa.load(await Bun.file('data/finals2000A.txt').arrayBuffer())
const t = timeYMDHMS(2020, 10, 7, 12, 34, 56, Timescale.UTC)
let t = timeYMDHMS(2020, 10, 7, 12, 34, 56, Timescale.UTC)
expect(iersa.delta(t)).toBe(-0.17181135242592593)
expect(iersa.xy(t)).toEqual([arcsec(0.1878143362962963), arcsec(0.3180433324074074)])

t = timeYMDHMS(2050, 10, 7, 12, 34, 56, Timescale.UTC)
expect(iersa.delta(t)).toBe(0.0862207)
expect(iersa.xy(t)).toEqual([arcsec(0.094347), arcsec(0.293316)])

t = timeYMDHMS(1900, 10, 7, 12, 34, 56, Timescale.UTC)
expect(iersa.delta(t)).toBe(0.8075)
expect(iersa.xy(t)).toEqual([arcsec(0.143), arcsec(0.137)])
})

test('iersB', async () => {
await iersb.load(await Bun.file('data/eopc04.1962-now.txt').arrayBuffer())
const t = timeYMDHMS(2020, 10, 7, 12, 34, 56, Timescale.UTC)
let t = timeYMDHMS(2020, 10, 7, 12, 34, 56, Timescale.UTC)
expect(iersb.delta(t)).toBe(-0.17180533112962962)
expect(iersb.xy(t)).toEqual([arcsec(0.1878133848148148), arcsec(0.3179746625925926)])

t = timeYMDHMS(2050, 10, 7, 12, 34, 56, Timescale.UTC)
expect(iersb.delta(t)).toBe(0.0523072)
expect(iersb.xy(t)).toEqual([arcsec(0.202982), arcsec(0.338377)])

t = timeYMDHMS(1900, 10, 7, 12, 34, 56, Timescale.UTC)
expect(iersb.delta(t)).toBe(0.0326338)
expect(iersb.xy(t)).toEqual([arcsec(-0.0127), arcsec(0.213)])
})
24 changes: 14 additions & 10 deletions src/iers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,20 @@ export class IersA extends IersBase {
this.clear()

return readLinesFromArrayBuffer(buffer, (line) => {
const mjd = parseFloat(line.substring(7, 15).trim())
const pmXa = parseFloat(line.substring(18, 27).trim())
const pmYa = parseFloat(line.substring(37, 46).trim())
const pmXb = parseFloat(line.substring(134, 144).trim())
const pmYb = parseFloat(line.substring(144, 154).trim())
const dut1a = parseFloat(line.substring(58, 68).trim())
const dut1b = parseFloat(line.substring(154, 165).trim())

this.mjd.push(mjd)
this.pmX.push(pmXb || pmXa)
this.pmY.push(pmYb || pmYa)
this.dut1.push(dut1b || dut1a)
if ((pmXb || pmXa) && (pmYb || pmYa) && (dut1b || dut1a)) {
const mjd = parseFloat(line.substring(7, 15).trim())
this.mjd.push(mjd)
this.pmX.push(pmXb || pmXa)
this.pmY.push(pmYb || pmYa)
this.dut1.push(dut1b || dut1a)
}
})
}
}
Expand All @@ -108,15 +110,17 @@ export class IersB extends IersBase {
return readLinesFromArrayBuffer(buffer, (line) => {
if (line.startsWith('#')) return

const mjd = parseFloat(line.substring(16, 26).trim())
const pmX = parseFloat(line.substring(26, 38).trim())
const pmY = parseFloat(line.substring(38, 50).trim())
const dut1 = parseFloat(line.substring(50, 62).trim())

this.mjd.push(mjd)
this.pmX.push(pmX)
this.pmY.push(pmY)
this.dut1.push(dut1)
if (pmX && pmY && dut1) {
const mjd = parseFloat(line.substring(16, 26).trim())
this.mjd.push(mjd)
this.pmX.push(pmX)
this.pmY.push(pmY)
this.dut1.push(dut1)
}
})
}
}
Expand Down

0 comments on commit 2170848

Please sign in to comment.