Skip to content

Commit 486ac03

Browse files
committed
Update README.md and LICENSE.md
1 parent 5926d23 commit 486ac03

File tree

9 files changed

+50
-41
lines changed

9 files changed

+50
-41
lines changed

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The Reproject.jl package is licensed under the MIT "Expat" License:
22

3-
> Copyright (c) 2019 Mosè Giordano
3+
> Copyright (c) 2019 Mosè Giordano, Rohit Kumar
44
>
55
> Permission is hereby granted, free of charge, to any person obtaining a copy
66
> of this software and associated documentation files (the "Software"), to deal

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "Reproject"
22
uuid = "d1dcc2e6-806e-11e9-2897-3f99785db2ae"
3-
authors = ["Mosè Giordano"]
3+
authors = ["Mosè Giordano", "Rohit Kumar"]
44
version = "0.1.0"
55

66
[deps]

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,14 @@
22

33
[![Build Status](https://travis-ci.com/giordano/Reproject.jl.svg?branch=master)](https://travis-ci.com/giordano/Reproject.jl)
44
[![Coveralls](https://coveralls.io/repos/github/giordano/Reproject.jl/badge.svg?branch=master)](https://coveralls.io/github/giordano/Reproject.jl?branch=master)
5+
6+
Implementation in [Julia](https://julialang.org/) of the
7+
[`reproject`](https://github.com/astropy/reproject) package by Thomas
8+
Robitaille, part of the Astropy project.
9+
10+
License
11+
-------
12+
13+
The `reproject` package is released under the terms of the BSD 3-Clause "New" or
14+
"Revised" License. The `Reproject.jl` package received written permission to be
15+
released under the MIT "Expat" License.

src/core.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,25 @@ function reproject(input_data, output_projection; shape_out = nothing, order::In
2222
else
2323
array_in, wcs_out = parse_input_data(input_data, hdu_in)
2424
end
25-
25+
2626
if output_projection isa FITS || output_projection isa String
2727
wcs_in, shape_out = parse_output_projection(output_projection, hdu_out)
2828
else
2929
wcs_in, shape_out = parse_output_projection(output_projection, shape_out)
3030
end
31-
31+
3232
type_in = wcs_to_celestial_frame(wcs_in)
3333
type_out = wcs_to_celestial_frame(wcs_out)
34-
34+
3535
if type_in == type_out && shape_out === nothing
3636
return array_in
3737
end
38-
38+
3939
img_out = fill(NaN, shape_out)
40-
40+
4141
itp = interpolator(array_in, order)
4242
shape_in = size(array_in)
43-
43+
4444
for i in 1:shape_out[1]
4545
for j in 1:shape_out[2]
4646
pix_coord_in = [float(i), float(j)]
@@ -68,12 +68,12 @@ function reproject(input_data, output_projection; shape_out = nothing, order::In
6868

6969
pix_coord_out = world_to_pix(wcs_out, [rad2deg(lon(coord_out)), rad2deg(lat(coord_out))])
7070

71-
if 1 <= pix_coord_out[1] <= shape_in[1] && 1 <= pix_coord_out[2] <= shape_in[2]
71+
if 1 <= pix_coord_out[1] <= shape_in[1] && 1 <= pix_coord_out[2] <= shape_in[2]
7272
img_out[i,j] = itp(pix_coord_out[1], pix_coord_out[2])
7373
end
7474
end
7575
end
76-
76+
7777
return img_out, (!isnan).(img_out)
7878
end
7979

@@ -91,6 +91,6 @@ function interpolator(array_in::AbstractArray, order::Int)
9191
else
9292
itp = interpolate(array_in, BSpline(Quadratic(InPlace(OnCell()))))
9393
end
94-
94+
9595
return itp
9696
end

src/parsers.jl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ Parse input data and returns an Array and WCS object.
77
88
# Arguments
99
- `input_data`: image to reproject which can be name of a FITS file,
10-
an ImageHDU or a FITS file.
11-
- `hdu_in`: used to set HDU to use when more than one HDU is present.
10+
an ImageHDU or a FITS file.
11+
- `hdu_in`: used to set HDU to use when more than one HDU is present.
1212
"""
1313
function parse_input_data(input_data::ImageHDU)
1414
return read(input_data), WCS.from_header(read_header(input_data, String))[1]
@@ -35,7 +35,7 @@ end
3535
Parse output projection and returns a WCS object and shape of output.
3636
3737
# Arguments
38-
- `output_projection`: WCS information about the image to be reprojected which can be
38+
- `output_projection`: WCS information about the image to be reprojected which can be
3939
name of a FITS file, an ImageHDU or WCSTransform.
4040
- `shape_out`: shape of the output image.
4141
- `hdu_number`: specifies HDU number when file name is given as input.
@@ -65,13 +65,12 @@ end
6565

6666
function parse_output_projection(output_projection::FITS, hdu_number)
6767
wcs_out = WCS.from_header(read_header(output_projection[hdu_number], String))[1]
68-
68+
6969
if output_projection[hdu_number] isa ImageHDU
7070
shape_out = size(output_projection[hdu_number])
71-
else
71+
else
7272
throw(ArgumentError("Given FITS file doesn't have ImageHDU"))
7373
end
74-
74+
7575
return wcs_out, shape_out
7676
end
77-

src/utils.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ The reference frame supported in Julia are FK5, ICRS and Galactic.
66
"""
77
function wcs_to_celestial_frame(wcs::WCSTransform)
88
radesys = wcs.radesys
9-
9+
1010
xcoord = wcs.ctype[1][1:4]
1111
ycoord = wcs.ctype[2][1:4]
12-
12+
1313
if radesys == ""
1414
if xcoord == "GLON" && ycoord == "GLAT"
1515
radesys = "Gal"
1616
elseif xcoord == "TLON" && ycoord == "TLAT"
1717
radesys = "ITRS"
1818
end
1919
end
20-
20+
2121
return radesys
2222
end

test/core.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
mkpath("data")
88
download("https://astropy.stsci.edu/data/galactic_center/gc_msx_e.fits", "data/gc_msx_e.fits")
99
end
10-
10+
1111
imgin = FITS("data/gc_msx_e.fits") # project this
1212
imgout = FITS("data/gc_2mass_k.fits") # into this coordinate
13-
13+
1414
hdu1 = astropy.io.fits.open("data/gc_2mass_k.fits")[1]
1515
hdu2 = astropy.io.fits.open("data/gc_msx_e.fits")[1]
16-
16+
1717
function check_diff(arr1, arr2)
1818
diff = 1e-3
1919
count = 0
@@ -26,14 +26,14 @@
2626
end
2727
return iszero(count)
2828
end
29-
29+
3030
@test check_diff(reproject(imgin, imgout, order = 0)[1], rp.reproject_interp(hdu2, hdu1.header, order = 0)[1]) == true
3131
@test check_diff(reproject(imgout, imgin, order = 0)[1], rp.reproject_interp(hdu1, hdu2.header, order = 0)[1]) == true
3232
@test check_diff(reproject(imgin, imgout, order = 1)[1], rp.reproject_interp(hdu2, hdu1.header, order = 1)[1]) == true
3333
@test check_diff(reproject(imgin, imgout, order = 2)[1], rp.reproject_interp(hdu2, hdu1.header, order = 2)[1]) == true
3434
@test check_diff(reproject(imgin[1], imgout[1], shape_out = (1000,1000))[1],
3535
rp.reproject_interp(hdu2, astropy.wcs.WCS(hdu1.header), shape_out = (1000,1000))[1]) == true
36-
36+
3737
wcs = WCSTransform(2; ctype = ["RA---AIR", "DEC--AIR"], radesys = "UNK")
3838
@test_throws ArgumentError reproject(imgin, wcs, shape_out = (100,100))
3939

test/parsers.jl

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,30 @@ using Reproject: parse_input_data, parse_output_projection
1414

1515
indata = reshape(Float32[1:100;], 5, 20)
1616
write(f, indata; header=inhdr)
17-
17+
1818
@testset "ImageHDU type" begin
1919
result = parse_input_data(f[1])
2020
@test result[1] isa Array
2121
@test result[2] isa WCSTransform
2222
end
23-
23+
2424
@testset "Single HDU FITS file" begin
2525
result = parse_input_data(f, 1)
2626
@test result[1] isa Array
2727
@test result[2] isa WCSTransform
2828
end
2929
close(f)
30-
30+
3131
@testset "String filename input" begin
3232
result = parse_input_data(fname, 1)
3333
@test result[1] isa Array
3434
@test result[2] isa WCSTransform
3535
end
36-
36+
3737
f = FITS(fname, "w")
3838
write(f, indata; header=inhdr)
3939
write(f, indata; header=inhdr)
40-
40+
4141
@testset "Multiple HDU FITS file" begin
4242
result = parse_input_data(f, 2)
4343
@test result[1] isa Array
@@ -47,7 +47,7 @@ using Reproject: parse_input_data, parse_output_projection
4747
result = parse_input_data(fname, 1)
4848
@test result[1] isa Array
4949
@test result[2] isa WCSTransform
50-
end
50+
end
5151
end
5252

5353
@testset "output parser" begin
@@ -65,33 +65,32 @@ end
6565

6666
indata = reshape(Float32[1:100;], 5, 20)
6767
write(f, indata; header=inhdr)
68-
68+
6969
@testset "ImageHDU type" begin
7070
result = parse_output_projection(f[1], (12,12))
7171
@test result[1] isa WCSTransform
7272
@test result[2] isa Tuple
7373
@test_throws DomainError parse_output_projection(f[1], ())
7474
end
7575
close(f)
76-
76+
7777
@testset "String filename" begin
7878
result = parse_output_projection(fname, 1)
7979
@test result[1] isa WCSTransform
8080
@test result[2] isa Tuple
8181
end
82-
82+
8383
wcs = WCSTransform(2;
8484
cdelt = [-0.066667, 0.066667],
8585
ctype = ["RA---AIR", "DEC--AIR"],
8686
crpix = [-234.75, 8.3393],
8787
crval = [0., -90],
8888
pv = [(2, 1, 45.0)])
89-
89+
9090
@testset "WCSTransform input" begin
9191
result = parse_output_projection(wcs, (12,12))
9292
@test result[1] isa WCSTransform
9393
@test result[2] isa Tuple
9494
@test_throws DomainError parse_output_projection(wcs, ())
9595
end
9696
end
97-

test/utils.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ using Reproject: wcs_to_celestial_frame
55
)
66
wcs2 = WCSTransform(2;
77
ctype = ["RA---AIR", "DEC--AIR"],
8-
equinox = 1888.67
8+
equinox = 1888.67
99
)
1010
wcs3 = WCSTransform(2;
1111
ctype = ["RA---AIR", "DEC--AIR"],
12-
equinox = 2000
12+
equinox = 2000
1313
)
1414
wcs4 = WCSTransform(2;
15-
ctype = ["GLON--", "GLAT--"],
15+
ctype = ["GLON--", "GLAT--"],
1616
)
1717
wcs5 = WCSTransform(2;
1818
ctype = ["TLON", "TLAT"],
1919
)
2020
wcs6 = WCSTransform(2;
2121
ctype = ["RA---AIR", "DEC--AIR"],
22-
radesys = "UNK"
22+
radesys = "UNK"
2323
)
2424

2525
@test wcs_to_celestial_frame(wcs1) == "ICRS"

0 commit comments

Comments
 (0)