Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Liu Dezi
csst_msc_sim
Commits
29ac5666
Commit
29ac5666
authored
Apr 07, 2021
by
Fang Yuedong
Browse files
Baseline
parents
Changes
830
Show whitespace changes
Inline
Side-by-side
ObservationSim/PSF/PSFInterp/libCentroid/nrutil.c
0 → 100644
View file @
29ac5666
#if defined(__STDC__) || defined(ANSI) || defined(NRANSI)
/* ANSI */
#include
<stdio.h>
#include
<stddef.h>
#include
<stdlib.h>
#define NR_END 1
#define FREE_ARG char*
void
nrerror
(
char
error_text
[])
/* Numerical Recipes standard error handler */
{
fprintf
(
stderr
,
"Numerical Recipes run-time error...
\n
"
);
fprintf
(
stderr
,
"%s
\n
"
,
error_text
);
fprintf
(
stderr
,
"...now exiting to system...
\n
"
);
exit
(
1
);
}
float
*
vector
(
long
nl
,
long
nh
)
/* allocate a float vector with subscript range v[nl..nh] */
{
float
*
v
;
v
=
(
float
*
)
malloc
((
size_t
)
((
nh
-
nl
+
1
+
NR_END
)
*
sizeof
(
float
)));
if
(
!
v
)
nrerror
(
"allocation failure in vector()"
);
return
v
-
nl
+
NR_END
;
}
int
*
ivector
(
long
nl
,
long
nh
)
/* allocate an int vector with subscript range v[nl..nh] */
{
int
*
v
;
v
=
(
int
*
)
malloc
((
size_t
)
((
nh
-
nl
+
1
+
NR_END
)
*
sizeof
(
int
)));
if
(
!
v
)
nrerror
(
"allocation failure in ivector()"
);
return
v
-
nl
+
NR_END
;
}
unsigned
char
*
cvector
(
long
nl
,
long
nh
)
/* allocate an unsigned char vector with subscript range v[nl..nh] */
{
unsigned
char
*
v
;
v
=
(
unsigned
char
*
)
malloc
((
size_t
)
((
nh
-
nl
+
1
+
NR_END
)
*
sizeof
(
unsigned
char
)));
if
(
!
v
)
nrerror
(
"allocation failure in cvector()"
);
return
v
-
nl
+
NR_END
;
}
unsigned
long
*
lvector
(
long
nl
,
long
nh
)
/* allocate an unsigned long vector with subscript range v[nl..nh] */
{
unsigned
long
*
v
;
v
=
(
unsigned
long
*
)
malloc
((
size_t
)
((
nh
-
nl
+
1
+
NR_END
)
*
sizeof
(
long
)));
if
(
!
v
)
nrerror
(
"allocation failure in lvector()"
);
return
v
-
nl
+
NR_END
;
}
double
*
dvector
(
long
nl
,
long
nh
)
/* allocate a double vector with subscript range v[nl..nh] */
{
double
*
v
;
v
=
(
double
*
)
malloc
((
size_t
)
((
nh
-
nl
+
1
+
NR_END
)
*
sizeof
(
double
)));
if
(
!
v
)
nrerror
(
"allocation failure in dvector()"
);
return
v
-
nl
+
NR_END
;
}
float
**
matrix
(
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
)
/* allocate a float matrix with subscript range m[nrl..nrh][ncl..nch] */
{
long
i
,
nrow
=
nrh
-
nrl
+
1
,
ncol
=
nch
-
ncl
+
1
;
float
**
m
;
/* allocate pointers to rows */
m
=
(
float
**
)
malloc
((
size_t
)((
nrow
+
NR_END
)
*
sizeof
(
float
*
)));
if
(
!
m
)
nrerror
(
"allocation failure 1 in matrix()"
);
m
+=
NR_END
;
m
-=
nrl
;
/* allocate rows and set pointers to them */
m
[
nrl
]
=
(
float
*
)
malloc
((
size_t
)((
nrow
*
ncol
+
NR_END
)
*
sizeof
(
float
)));
if
(
!
m
[
nrl
])
nrerror
(
"allocation failure 2 in matrix()"
);
m
[
nrl
]
+=
NR_END
;
m
[
nrl
]
-=
ncl
;
for
(
i
=
nrl
+
1
;
i
<=
nrh
;
i
++
)
m
[
i
]
=
m
[
i
-
1
]
+
ncol
;
/* return pointer to array of pointers to rows */
return
m
;
}
double
**
dmatrix
(
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
)
/* allocate a double matrix with subscript range m[nrl..nrh][ncl..nch] */
{
long
i
,
nrow
=
nrh
-
nrl
+
1
,
ncol
=
nch
-
ncl
+
1
;
double
**
m
;
/* allocate pointers to rows */
m
=
(
double
**
)
malloc
((
size_t
)((
nrow
+
NR_END
)
*
sizeof
(
double
*
)));
if
(
!
m
)
nrerror
(
"allocation failure 1 in matrix()"
);
m
+=
NR_END
;
m
-=
nrl
;
/* allocate rows and set pointers to them */
m
[
nrl
]
=
(
double
*
)
malloc
((
size_t
)((
nrow
*
ncol
+
NR_END
)
*
sizeof
(
double
)));
if
(
!
m
[
nrl
])
nrerror
(
"allocation failure 2 in matrix()"
);
m
[
nrl
]
+=
NR_END
;
m
[
nrl
]
-=
ncl
;
for
(
i
=
nrl
+
1
;
i
<=
nrh
;
i
++
)
m
[
i
]
=
m
[
i
-
1
]
+
ncol
;
/* return pointer to array of pointers to rows */
return
m
;
}
int
**
imatrix
(
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
)
/* allocate a int matrix with subscript range m[nrl..nrh][ncl..nch] */
{
long
i
,
nrow
=
nrh
-
nrl
+
1
,
ncol
=
nch
-
ncl
+
1
;
int
**
m
;
/* allocate pointers to rows */
m
=
(
int
**
)
malloc
((
size_t
)((
nrow
+
NR_END
)
*
sizeof
(
int
*
)));
if
(
!
m
)
nrerror
(
"allocation failure 1 in matrix()"
);
m
+=
NR_END
;
m
-=
nrl
;
/* allocate rows and set pointers to them */
m
[
nrl
]
=
(
int
*
)
malloc
((
size_t
)((
nrow
*
ncol
+
NR_END
)
*
sizeof
(
int
)));
if
(
!
m
[
nrl
])
nrerror
(
"allocation failure 2 in matrix()"
);
m
[
nrl
]
+=
NR_END
;
m
[
nrl
]
-=
ncl
;
for
(
i
=
nrl
+
1
;
i
<=
nrh
;
i
++
)
m
[
i
]
=
m
[
i
-
1
]
+
ncol
;
/* return pointer to array of pointers to rows */
return
m
;
}
float
**
submatrix
(
float
**
a
,
long
oldrl
,
long
oldrh
,
long
oldcl
,
long
oldch
,
long
newrl
,
long
newcl
)
/* point a submatrix [newrl..][newcl..] to a[oldrl..oldrh][oldcl..oldch] */
{
long
i
,
j
,
nrow
=
oldrh
-
oldrl
+
1
,
ncol
=
oldcl
-
newcl
;
float
**
m
;
/* allocate array of pointers to rows */
m
=
(
float
**
)
malloc
((
size_t
)
((
nrow
+
NR_END
)
*
sizeof
(
float
*
)));
if
(
!
m
)
nrerror
(
"allocation failure in submatrix()"
);
m
+=
NR_END
;
m
-=
newrl
;
/* set pointers to rows */
for
(
i
=
oldrl
,
j
=
newrl
;
i
<=
oldrh
;
i
++
,
j
++
)
m
[
j
]
=
a
[
i
]
+
ncol
;
/* return pointer to array of pointers to rows */
return
m
;
}
float
**
convert_matrix
(
float
*
a
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
)
/* allocate a float matrix m[nrl..nrh][ncl..nch] that points to the matrix
declared in the standard C manner as a[nrow][ncol], where nrow=nrh-nrl+1
and ncol=nch-ncl+1. The routine should be called with the address
&a[0][0] as the first argument. */
{
long
i
,
j
,
nrow
=
nrh
-
nrl
+
1
,
ncol
=
nch
-
ncl
+
1
;
float
**
m
;
/* allocate pointers to rows */
m
=
(
float
**
)
malloc
((
size_t
)
((
nrow
+
NR_END
)
*
sizeof
(
float
*
)));
if
(
!
m
)
nrerror
(
"allocation failure in convert_matrix()"
);
m
+=
NR_END
;
m
-=
nrl
;
/* set pointers to rows */
m
[
nrl
]
=
a
-
ncl
;
for
(
i
=
1
,
j
=
nrl
+
1
;
i
<
nrow
;
i
++
,
j
++
)
m
[
j
]
=
m
[
j
-
1
]
+
ncol
;
/* return pointer to array of pointers to rows */
return
m
;
}
float
***
f3tensor
(
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
,
long
ndl
,
long
ndh
)
/* allocate a float 3tensor with range t[nrl..nrh][ncl..nch][ndl..ndh] */
{
long
i
,
j
,
nrow
=
nrh
-
nrl
+
1
,
ncol
=
nch
-
ncl
+
1
,
ndep
=
ndh
-
ndl
+
1
;
float
***
t
;
/* allocate pointers to pointers to rows */
t
=
(
float
***
)
malloc
((
size_t
)((
nrow
+
NR_END
)
*
sizeof
(
float
**
)));
if
(
!
t
)
nrerror
(
"allocation failure 1 in f3tensor()"
);
t
+=
NR_END
;
t
-=
nrl
;
/* allocate pointers to rows and set pointers to them */
t
[
nrl
]
=
(
float
**
)
malloc
((
size_t
)((
nrow
*
ncol
+
NR_END
)
*
sizeof
(
float
*
)));
if
(
!
t
[
nrl
])
nrerror
(
"allocation failure 2 in f3tensor()"
);
t
[
nrl
]
+=
NR_END
;
t
[
nrl
]
-=
ncl
;
/* allocate rows and set pointers to them */
t
[
nrl
][
ncl
]
=
(
float
*
)
malloc
((
size_t
)((
nrow
*
ncol
*
ndep
+
NR_END
)
*
sizeof
(
float
)));
if
(
!
t
[
nrl
][
ncl
])
nrerror
(
"allocation failure 3 in f3tensor()"
);
t
[
nrl
][
ncl
]
+=
NR_END
;
t
[
nrl
][
ncl
]
-=
ndl
;
for
(
j
=
ncl
+
1
;
j
<=
nch
;
j
++
)
t
[
nrl
][
j
]
=
t
[
nrl
][
j
-
1
]
+
ndep
;
for
(
i
=
nrl
+
1
;
i
<=
nrh
;
i
++
)
{
t
[
i
]
=
t
[
i
-
1
]
+
ncol
;
t
[
i
][
ncl
]
=
t
[
i
-
1
][
ncl
]
+
ncol
*
ndep
;
for
(
j
=
ncl
+
1
;
j
<=
nch
;
j
++
)
t
[
i
][
j
]
=
t
[
i
][
j
-
1
]
+
ndep
;
}
/* return pointer to array of pointers to rows */
return
t
;
}
double
***
d3tensor
(
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
,
long
ndl
,
long
ndh
)
/* allocate a double 3tensor with range t[nrl..nrh][ncl..nch][ndl..ndh] */
{
long
i
,
j
,
nrow
=
nrh
-
nrl
+
1
,
ncol
=
nch
-
ncl
+
1
,
ndep
=
ndh
-
ndl
+
1
;
double
***
t
;
/* allocate pointers to pointers to rows */
t
=
(
double
***
)
malloc
((
size_t
)((
nrow
+
NR_END
)
*
sizeof
(
double
**
)));
if
(
!
t
)
nrerror
(
"allocation failure 1 in f3tensor()"
);
t
+=
NR_END
;
t
-=
nrl
;
/* allocate pointers to rows and set pointers to them */
t
[
nrl
]
=
(
double
**
)
malloc
((
size_t
)((
nrow
*
ncol
+
NR_END
)
*
sizeof
(
double
*
)));
if
(
!
t
[
nrl
])
nrerror
(
"allocation failure 2 in f3tensor()"
);
t
[
nrl
]
+=
NR_END
;
t
[
nrl
]
-=
ncl
;
/* allocate rows and set pointers to them */
t
[
nrl
][
ncl
]
=
(
double
*
)
malloc
((
size_t
)((
nrow
*
ncol
*
ndep
+
NR_END
)
*
sizeof
(
double
)));
if
(
!
t
[
nrl
][
ncl
])
nrerror
(
"allocation failure 3 in f3tensor()"
);
t
[
nrl
][
ncl
]
+=
NR_END
;
t
[
nrl
][
ncl
]
-=
ndl
;
for
(
j
=
ncl
+
1
;
j
<=
nch
;
j
++
)
t
[
nrl
][
j
]
=
t
[
nrl
][
j
-
1
]
+
ndep
;
for
(
i
=
nrl
+
1
;
i
<=
nrh
;
i
++
)
{
t
[
i
]
=
t
[
i
-
1
]
+
ncol
;
t
[
i
][
ncl
]
=
t
[
i
-
1
][
ncl
]
+
ncol
*
ndep
;
for
(
j
=
ncl
+
1
;
j
<=
nch
;
j
++
)
t
[
i
][
j
]
=
t
[
i
][
j
-
1
]
+
ndep
;
}
/* return pointer to array of pointers to rows */
return
t
;
}
unsigned
char
**
cmatrix
(
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
)
/* allocate a int matrix with subscript range m[nrl..nrh][ncl..nch] */
{
long
i
,
nrow
=
nrh
-
nrl
+
1
,
ncol
=
nch
-
ncl
+
1
;
unsigned
char
**
m
;
/* allocate pointers to rows */
m
=
(
unsigned
char
**
)
malloc
((
size_t
)((
nrow
+
NR_END
)
*
sizeof
(
unsigned
char
*
)));
if
(
!
m
)
nrerror
(
"allocation failure 1 in matrix()"
);
m
+=
NR_END
;
m
-=
nrl
;
/* allocate rows and set pointers to them */
m
[
nrl
]
=
(
unsigned
char
*
)
malloc
((
size_t
)((
nrow
*
ncol
+
NR_END
)
*
sizeof
(
unsigned
char
)));
if
(
!
m
[
nrl
])
nrerror
(
"allocation failure 2 in matrix()"
);
m
[
nrl
]
+=
NR_END
;
m
[
nrl
]
-=
ncl
;
for
(
i
=
nrl
+
1
;
i
<=
nrh
;
i
++
)
m
[
i
]
=
m
[
i
-
1
]
+
ncol
;
/* return pointer to array of pointers to rows */
return
m
;
}
void
free_vector
(
float
*
v
,
long
nl
,
long
nh
)
/* free a float vector allocated with vector() */
{
free
((
FREE_ARG
)
(
v
+
nl
-
NR_END
));
}
void
free_ivector
(
int
*
v
,
long
nl
,
long
nh
)
/* free an int vector allocated with ivector() */
{
free
((
FREE_ARG
)
(
v
+
nl
-
NR_END
));
}
void
free_cvector
(
unsigned
char
*
v
,
long
nl
,
long
nh
)
/* free an unsigned char vector allocated with cvector() */
{
free
((
FREE_ARG
)
(
v
+
nl
-
NR_END
));
}
void
free_lvector
(
unsigned
long
*
v
,
long
nl
,
long
nh
)
/* free an unsigned long vector allocated with lvector() */
{
free
((
FREE_ARG
)
(
v
+
nl
-
NR_END
));
}
void
free_dvector
(
double
*
v
,
long
nl
,
long
nh
)
/* free a double vector allocated with dvector() */
{
free
((
FREE_ARG
)
(
v
+
nl
-
NR_END
));
}
void
free_matrix
(
float
**
m
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
)
/* free a float matrix allocated by matrix() */
{
free
((
FREE_ARG
)
(
m
[
nrl
]
+
ncl
-
NR_END
));
free
((
FREE_ARG
)
(
m
+
nrl
-
NR_END
));
}
void
free_dmatrix
(
double
**
m
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
)
/* free a double matrix allocated by dmatrix() */
{
free
((
FREE_ARG
)
(
m
[
nrl
]
+
ncl
-
NR_END
));
free
((
FREE_ARG
)
(
m
+
nrl
-
NR_END
));
}
void
free_imatrix
(
int
**
m
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
)
/* free an int matrix allocated by imatrix() */
{
free
((
FREE_ARG
)
(
m
[
nrl
]
+
ncl
-
NR_END
));
free
((
FREE_ARG
)
(
m
+
nrl
-
NR_END
));
}
void
free_submatrix
(
float
**
b
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
)
/* free a submatrix allocated by submatrix() */
{
free
((
FREE_ARG
)
(
b
+
nrl
-
NR_END
));
}
void
free_convert_matrix
(
float
**
b
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
)
/* free a matrix allocated by convert_matrix() */
{
free
((
FREE_ARG
)
(
b
+
nrl
-
NR_END
));
}
void
free_f3tensor
(
float
***
t
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
,
long
ndl
,
long
ndh
)
/* free a float f3tensor allocated by f3tensor() */
{
free
((
FREE_ARG
)
(
t
[
nrl
][
ncl
]
+
ndl
-
NR_END
));
free
((
FREE_ARG
)
(
t
[
nrl
]
+
ncl
-
NR_END
));
free
((
FREE_ARG
)
(
t
+
nrl
-
NR_END
));
}
void
free_d3tensor
(
double
***
t
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
,
long
ndl
,
long
ndh
)
/* free a double f3tensor allocated by f3tensor() */
{
free
((
FREE_ARG
)
(
t
[
nrl
][
ncl
]
+
ndl
-
NR_END
));
free
((
FREE_ARG
)
(
t
[
nrl
]
+
ncl
-
NR_END
));
free
((
FREE_ARG
)
(
t
+
nrl
-
NR_END
));
}
void
free_cmatrix
(
unsigned
char
**
m
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
)
/* free a character matrix allocated by matrix() */
{
free
((
FREE_ARG
)
(
m
[
nrl
]
+
ncl
-
NR_END
));
free
((
FREE_ARG
)
(
m
+
nrl
-
NR_END
));
}
#else
/* ANSI */
/* traditional - K&R */
#include
<stdio.h>
#define NR_END 1
#define FREE_ARG char*
void
nrerror
(
error_text
)
char
error_text
[];
/* Numerical Recipes standard error handler */
{
void
exit
();
fprintf
(
stderr
,
"Numerical Recipes run-time error...
\n
"
);
fprintf
(
stderr
,
"%s
\n
"
,
error_text
);
fprintf
(
stderr
,
"...now exiting to system...
\n
"
);
exit
(
1
);
}
float
*
vector
(
nl
,
nh
)
long
nh
,
nl
;
/* allocate a float vector with subscript range v[nl..nh] */
{
float
*
v
;
v
=
(
float
*
)
malloc
((
unsigned
int
)
((
nh
-
nl
+
1
+
NR_END
)
*
sizeof
(
float
)));
if
(
!
v
)
nrerror
(
"allocation failure in vector()"
);
return
v
-
nl
+
NR_END
;
}
int
*
ivector
(
nl
,
nh
)
long
nh
,
nl
;
/* allocate an int vector with subscript range v[nl..nh] */
{
int
*
v
;
v
=
(
int
*
)
malloc
((
unsigned
int
)
((
nh
-
nl
+
1
+
NR_END
)
*
sizeof
(
int
)));
if
(
!
v
)
nrerror
(
"allocation failure in ivector()"
);
return
v
-
nl
+
NR_END
;
}
unsigned
char
*
cvector
(
nl
,
nh
)
long
nh
,
nl
;
/* allocate an unsigned char vector with subscript range v[nl..nh] */
{
unsigned
char
*
v
;
v
=
(
unsigned
char
*
)
malloc
((
unsigned
int
)
((
nh
-
nl
+
1
+
NR_END
)
*
sizeof
(
unsigned
char
)));
if
(
!
v
)
nrerror
(
"allocation failure in cvector()"
);
return
v
-
nl
+
NR_END
;
}
unsigned
long
*
lvector
(
nl
,
nh
)
long
nh
,
nl
;
/* allocate an unsigned long vector with subscript range v[nl..nh] */
{
unsigned
long
*
v
;
v
=
(
unsigned
long
*
)
malloc
((
unsigned
int
)
((
nh
-
nl
+
1
+
NR_END
)
*
sizeof
(
long
)));
if
(
!
v
)
nrerror
(
"allocation failure in lvector()"
);
return
v
-
nl
+
NR_END
;
}
double
*
dvector
(
nl
,
nh
)
long
nh
,
nl
;
/* allocate a double vector with subscript range v[nl..nh] */
{
double
*
v
;
v
=
(
double
*
)
malloc
((
unsigned
int
)
((
nh
-
nl
+
1
+
NR_END
)
*
sizeof
(
double
)));
if
(
!
v
)
nrerror
(
"allocation failure in dvector()"
);
return
v
-
nl
+
NR_END
;
}
float
**
matrix
(
nrl
,
nrh
,
ncl
,
nch
)
long
nch
,
ncl
,
nrh
,
nrl
;
/* allocate a float matrix with subscript range m[nrl..nrh][ncl..nch] */
{
long
i
,
nrow
=
nrh
-
nrl
+
1
,
ncol
=
nch
-
ncl
+
1
;
float
**
m
;
/* allocate pointers to rows */
m
=
(
float
**
)
malloc
((
unsigned
int
)((
nrow
+
NR_END
)
*
sizeof
(
float
*
)));
if
(
!
m
)
nrerror
(
"allocation failure 1 in matrix()"
);
m
+=
NR_END
;
m
-=
nrl
;
/* allocate rows and set pointers to them */
m
[
nrl
]
=
(
float
*
)
malloc
((
unsigned
int
)((
nrow
*
ncol
+
NR_END
)
*
sizeof
(
float
)));
if
(
!
m
[
nrl
])
nrerror
(
"allocation failure 2 in matrix()"
);
m
[
nrl
]
+=
NR_END
;
m
[
nrl
]
-=
ncl
;
for
(
i
=
nrl
+
1
;
i
<=
nrh
;
i
++
)
m
[
i
]
=
m
[
i
-
1
]
+
ncol
;
/* return pointer to array of pointers to rows */
return
m
;
}
double
**
dmatrix
(
nrl
,
nrh
,
ncl
,
nch
)
long
nch
,
ncl
,
nrh
,
nrl
;
/* allocate a double matrix with subscript range m[nrl..nrh][ncl..nch] */
{
long
i
,
nrow
=
nrh
-
nrl
+
1
,
ncol
=
nch
-
ncl
+
1
;
double
**
m
;
/* allocate pointers to rows */
m
=
(
double
**
)
malloc
((
unsigned
int
)((
nrow
+
NR_END
)
*
sizeof
(
double
*
)));
if
(
!
m
)
nrerror
(
"allocation failure 1 in matrix()"
);
m
+=
NR_END
;
m
-=
nrl
;
/* allocate rows and set pointers to them */
m
[
nrl
]
=
(
double
*
)
malloc
((
unsigned
int
)((
nrow
*
ncol
+
NR_END
)
*
sizeof
(
double
)));
if
(
!
m
[
nrl
])
nrerror
(
"allocation failure 2 in matrix()"
);
m
[
nrl
]
+=
NR_END
;
m
[
nrl
]
-=
ncl
;
for
(
i
=
nrl
+
1
;
i
<=
nrh
;
i
++
)
m
[
i
]
=
m
[
i
-
1
]
+
ncol
;
/* return pointer to array of pointers to rows */
return
m
;
}
int
**
imatrix
(
nrl
,
nrh
,
ncl
,
nch
)
long
nch
,
ncl
,
nrh
,
nrl
;
/* allocate a int matrix with subscript range m[nrl..nrh][ncl..nch] */
{
long
i
,
nrow
=
nrh
-
nrl
+
1
,
ncol
=
nch
-
ncl
+
1
;
int
**
m
;
/* allocate pointers to rows */
m
=
(
int
**
)
malloc
((
unsigned
int
)((
nrow
+
NR_END
)
*
sizeof
(
int
*
)));
if
(
!
m
)
nrerror
(
"allocation failure 1 in matrix()"
);
m
+=
NR_END
;
m
-=
nrl
;
/* allocate rows and set pointers to them */
m
[
nrl
]
=
(
int
*
)
malloc
((
unsigned
int
)((
nrow
*
ncol
+
NR_END
)
*
sizeof
(
int
)));
if
(
!
m
[
nrl
])
nrerror
(
"allocation failure 2 in matrix()"
);
m
[
nrl
]
+=
NR_END
;
m
[
nrl
]
-=
ncl
;
for
(
i
=
nrl
+
1
;
i
<=
nrh
;
i
++
)
m
[
i
]
=
m
[
i
-
1
]
+
ncol
;
/* return pointer to array of pointers to rows */
return
m
;
}
float
**
submatrix
(
a
,
oldrl
,
oldrh
,
oldcl
,
oldch
,
newrl
,
newcl
)
float
**
a
;
long
newcl
,
newrl
,
oldch
,
oldcl
,
oldrh
,
oldrl
;
/* point a submatrix [newrl..][newcl..] to a[oldrl..oldrh][oldcl..oldch] */
{
long
i
,
j
,
nrow
=
oldrh
-
oldrl
+
1
,
ncol
=
oldcl
-
newcl
;
float
**
m
;
/* allocate array of pointers to rows */
m
=
(
float
**
)
malloc
((
unsigned
int
)
((
nrow
+
NR_END
)
*
sizeof
(
float
*
)));
if
(
!
m
)
nrerror
(
"allocation failure in submatrix()"
);
m
+=
NR_END
;
m
-=
newrl
;
/* set pointers to rows */
for
(
i
=
oldrl
,
j
=
newrl
;
i
<=
oldrh
;
i
++
,
j
++
)
m
[
j
]
=
a
[
i
]
+
ncol
;
/* return pointer to array of pointers to rows */
return
m
;
}
float
**
convert_matrix
(
a
,
nrl
,
nrh
,
ncl
,
nch
)
float
*
a
;
long
nch
,
ncl
,
nrh
,
nrl
;
/* allocate a float matrix m[nrl..nrh][ncl..nch] that points to the matrix
declared in the standard C manner as a[nrow][ncol], where nrow=nrh-nrl+1
and ncol=nch-ncl+1. The routine should be called with the address
&a[0][0] as the first argument. */
{
long
i
,
j
,
nrow
=
nrh
-
nrl
+
1
,
ncol
=
nch
-
ncl
+
1
;
float
**
m
;
/* allocate pointers to rows */
m
=
(
float
**
)
malloc
((
unsigned
int
)
((
nrow
+
NR_END
)
*
sizeof
(
float
*
)));
if
(
!
m
)
nrerror
(
"allocation failure in convert_matrix()"
);
m
+=
NR_END
;
m
-=
nrl
;
/* set pointers to rows */
m
[
nrl
]
=
a
-
ncl
;
for
(
i
=
1
,
j
=
nrl
+
1
;
i
<
nrow
;
i
++
,
j
++
)
m
[
j
]
=
m
[
j
-
1
]
+
ncol
;
/* return pointer to array of pointers to rows */
return
m
;
}
double
***
d3tensor
(
nrl
,
nrh
,
ncl
,
nch
,
ndl
,
ndh
)
long
nch
,
ncl
,
ndh
,
ndl
,
nrh
,
nrl
;
/* allocate a float 3tensor with range t[nrl..nrh][ncl..nch][ndl..ndh] */
{
long
i
,
j
,
nrow
=
nrh
-
nrl
+
1
,
ncol
=
nch
-
ncl
+
1
,
ndep
=
ndh
-
ndl
+
1
;
double
***
t
;
/* allocate pointers to pointers to rows */
t
=
(
double
***
)
malloc
((
unsigned
int
)((
nrow
+
NR_END
)
*
sizeof
(
double
**
)));
if
(
!
t
)
nrerror
(
"allocation failure 1 in f3tensor()"
);
t
+=
NR_END
;
t
-=
nrl
;
/* allocate pointers to rows and set pointers to them */
t
[
nrl
]
=
(
double
**
)
malloc
((
unsigned
int
)((
nrow
*
ncol
+
NR_END
)
*
sizeof
(
double
*
)));
if
(
!
t
[
nrl
])
nrerror
(
"allocation failure 2 in f3tensor()"
);
t
[
nrl
]
+=
NR_END
;
t
[
nrl
]
-=
ncl
;
/* allocate rows and set pointers to them */
t
[
nrl
][
ncl
]
=
(
double
*
)
malloc
((
unsigned
int
)((
nrow
*
ncol
*
ndep
+
NR_END
)
*
sizeof
(
double
)));
if
(
!
t
[
nrl
][
ncl
])
nrerror
(
"allocation failure 3 in f3tensor()"
);
t
[
nrl
][
ncl
]
+=
NR_END
;
t
[
nrl
][
ncl
]
-=
ndl
;
for
(
j
=
ncl
+
1
;
j
<=
nch
;
j
++
)
t
[
nrl
][
j
]
=
t
[
nrl
][
j
-
1
]
+
ndep
;
for
(
i
=
nrl
+
1
;
i
<=
nrh
;
i
++
)
{
t
[
i
]
=
t
[
i
-
1
]
+
ncol
;
t
[
i
][
ncl
]
=
t
[
i
-
1
][
ncl
]
+
ncol
*
ndep
;
for
(
j
=
ncl
+
1
;
j
<=
nch
;
j
++
)
t
[
i
][
j
]
=
t
[
i
][
j
-
1
]
+
ndep
;
}
/* return pointer to array of pointers to rows */
return
t
;
}
float
***
f3tensor
(
nrl
,
nrh
,
ncl
,
nch
,
ndl
,
ndh
)
long
nch
,
ncl
,
ndh
,
ndl
,
nrh
,
nrl
;
/* allocate a float 3tensor with range t[nrl..nrh][ncl..nch][ndl..ndh] */
{
long
i
,
j
,
nrow
=
nrh
-
nrl
+
1
,
ncol
=
nch
-
ncl
+
1
,
ndep
=
ndh
-
ndl
+
1
;
float
***
t
;
/* allocate pointers to pointers to rows */
t
=
(
float
***
)
malloc
((
unsigned
int
)((
nrow
+
NR_END
)
*
sizeof
(
float
**
)));
if
(
!
t
)
nrerror
(
"allocation failure 1 in f3tensor()"
);
t
+=
NR_END
;
t
-=
nrl
;
/* allocate pointers to rows and set pointers to them */
t
[
nrl
]
=
(
float
**
)
malloc
((
unsigned
int
)((
nrow
*
ncol
+
NR_END
)
*
sizeof
(
float
*
)));
if
(
!
t
[
nrl
])
nrerror
(
"allocation failure 2 in f3tensor()"
);
t
[
nrl
]
+=
NR_END
;
t
[
nrl
]
-=
ncl
;
/* allocate rows and set pointers to them */
t
[
nrl
][
ncl
]
=
(
float
*
)
malloc
((
unsigned
int
)((
nrow
*
ncol
*
ndep
+
NR_END
)
*
sizeof
(
float
)));
if
(
!
t
[
nrl
][
ncl
])
nrerror
(
"allocation failure 3 in f3tensor()"
);
t
[
nrl
][
ncl
]
+=
NR_END
;
t
[
nrl
][
ncl
]
-=
ndl
;
for
(
j
=
ncl
+
1
;
j
<=
nch
;
j
++
)
t
[
nrl
][
j
]
=
t
[
nrl
][
j
-
1
]
+
ndep
;
for
(
i
=
nrl
+
1
;
i
<=
nrh
;
i
++
)
{
t
[
i
]
=
t
[
i
-
1
]
+
ncol
;
t
[
i
][
ncl
]
=
t
[
i
-
1
][
ncl
]
+
ncol
*
ndep
;
for
(
j
=
ncl
+
1
;
j
<=
nch
;
j
++
)
t
[
i
][
j
]
=
t
[
i
][
j
-
1
]
+
ndep
;
}
/* return pointer to array of pointers to rows */
return
t
;
}
unsigned
char
**
cmatrix
(
nrl
,
nrh
,
ncl
,
nch
)
long
nch
,
ncl
,
nrh
,
nrl
;
/* allocate a int matrix with subscript range m[nrl..nrh][ncl..nch] */
{
long
i
,
nrow
=
nrh
-
nrl
+
1
,
ncol
=
nch
-
ncl
+
1
;
unsigned
char
**
m
;
/* allocate pointers to rows */
m
=
(
unsigned
char
**
)
malloc
((
unsigned
int
)((
nrow
+
NR_END
)
*
sizeof
(
unsigned
char
*
)));
if
(
!
m
)
nrerror
(
"allocation failure 1 in matrix()"
);
m
+=
NR_END
;
m
-=
nrl
;
/* allocate rows and set pointers to them */
m
[
nrl
]
=
(
unsigned
char
*
)
malloc
((
unsigned
int
)((
nrow
*
ncol
+
NR_END
)
*
sizeof
(
unsigned
char
)));
if
(
!
m
[
nrl
])
nrerror
(
"allocation failure 2 in matrix()"
);
m
[
nrl
]
+=
NR_END
;
m
[
nrl
]
-=
ncl
;
for
(
i
=
nrl
+
1
;
i
<=
nrh
;
i
++
)
m
[
i
]
=
m
[
i
-
1
]
+
ncol
;
/* return pointer to array of pointers to rows */
return
m
;
}
void
free_vector
(
v
,
nl
,
nh
)
float
*
v
;
long
nh
,
nl
;
/* free a float vector allocated with vector() */
{
free
((
FREE_ARG
)
(
v
+
nl
-
NR_END
));
}
void
free_ivector
(
v
,
nl
,
nh
)
int
*
v
;
long
nh
,
nl
;
/* free an int vector allocated with ivector() */
{
free
((
FREE_ARG
)
(
v
+
nl
-
NR_END
));
}
void
free_cvector
(
v
,
nl
,
nh
)
long
nh
,
nl
;
unsigned
char
*
v
;
/* free an unsigned char vector allocated with cvector() */
{
free
((
FREE_ARG
)
(
v
+
nl
-
NR_END
));
}
void
free_lvector
(
v
,
nl
,
nh
)
long
nh
,
nl
;
unsigned
long
*
v
;
/* free an unsigned long vector allocated with lvector() */
{
free
((
FREE_ARG
)
(
v
+
nl
-
NR_END
));
}
void
free_dvector
(
v
,
nl
,
nh
)
double
*
v
;
long
nh
,
nl
;
/* free a double vector allocated with dvector() */
{
free
((
FREE_ARG
)
(
v
+
nl
-
NR_END
));
}
void
free_matrix
(
m
,
nrl
,
nrh
,
ncl
,
nch
)
float
**
m
;
long
nch
,
ncl
,
nrh
,
nrl
;
/* free a float matrix allocated by matrix() */
{
free
((
FREE_ARG
)
(
m
[
nrl
]
+
ncl
-
NR_END
));
free
((
FREE_ARG
)
(
m
+
nrl
-
NR_END
));
}
void
free_dmatrix
(
m
,
nrl
,
nrh
,
ncl
,
nch
)
double
**
m
;
long
nch
,
ncl
,
nrh
,
nrl
;
/* free a double matrix allocated by dmatrix() */
{
free
((
FREE_ARG
)
(
m
[
nrl
]
+
ncl
-
NR_END
));
free
((
FREE_ARG
)
(
m
+
nrl
-
NR_END
));
}
void
free_imatrix
(
m
,
nrl
,
nrh
,
ncl
,
nch
)
int
**
m
;
long
nch
,
ncl
,
nrh
,
nrl
;
/* free an int matrix allocated by imatrix() */
{
free
((
FREE_ARG
)
(
m
[
nrl
]
+
ncl
-
NR_END
));
free
((
FREE_ARG
)
(
m
+
nrl
-
NR_END
));
}
void
free_submatrix
(
b
,
nrl
,
nrh
,
ncl
,
nch
)
float
**
b
;
long
nch
,
ncl
,
nrh
,
nrl
;
/* free a submatrix allocated by submatrix() */
{
free
((
FREE_ARG
)
(
b
+
nrl
-
NR_END
));
}
void
free_convert_matrix
(
b
,
nrl
,
nrh
,
ncl
,
nch
)
float
**
b
;
long
nch
,
ncl
,
nrh
,
nrl
;
/* free a matrix allocated by convert_matrix() */
{
free
((
FREE_ARG
)
(
b
+
nrl
-
NR_END
));
}
void
free_f3tensor
(
t
,
nrl
,
nrh
,
ncl
,
nch
,
ndl
,
ndh
)
float
***
t
;
long
nch
,
ncl
,
ndh
,
ndl
,
nrh
,
nrl
;
/* free a float f3tensor allocated by f3tensor() */
{
free
((
FREE_ARG
)
(
t
[
nrl
][
ncl
]
+
ndl
-
NR_END
));
free
((
FREE_ARG
)
(
t
[
nrl
]
+
ncl
-
NR_END
));
free
((
FREE_ARG
)
(
t
+
nrl
-
NR_END
));
}
void
free_d3tensor
(
t
,
nrl
,
nrh
,
ncl
,
nch
,
ndl
,
ndh
)
double
***
t
;
long
nch
,
ncl
,
ndh
,
ndl
,
nrh
,
nrl
;
/* free a float f3tensor allocated by f3tensor() */
{
free
((
FREE_ARG
)
(
t
[
nrl
][
ncl
]
+
ndl
-
NR_END
));
free
((
FREE_ARG
)
(
t
[
nrl
]
+
ncl
-
NR_END
));
free
((
FREE_ARG
)
(
t
+
nrl
-
NR_END
));
}
void
free_cmatrix
(
m
,
nrl
,
nrh
,
ncl
,
nch
)
unsigned
**
m
;
long
nch
,
ncl
,
nrh
,
nrl
;
/* free a double matrix allocated by dmatrix() */
{
free
((
FREE_ARG
)
(
m
[
nrl
]
+
ncl
-
NR_END
));
free
((
FREE_ARG
)
(
m
+
nrl
-
NR_END
));
}
#endif
/* ANSI */
ObservationSim/PSF/PSFInterp/libCentroid/nrutil.h
0 → 100644
View file @
29ac5666
/* CAUTION: This is the ANSI C (only) version of the Numerical Recipes
utility file nrutil.h. Do not confuse this file with the same-named
file nrutil.h that may be supplied in a 'misc' subdirectory.
*That* file is the one from the book, and contains both ANSI and
traditional K&R versions, along with #ifdef macros to select the
correct version. *This* file contains only ANSI C. */
#ifndef _NR_UTILS_H_
#define _NR_UTILS_H_
static
float
sqrarg
;
#define SQR(a) ((sqrarg=(a)) == 0.0 ? 0.0 : sqrarg*sqrarg)
static
double
dsqrarg
;
#define DSQR(a) ((dsqrarg=(a)) == 0.0 ? 0.0 : dsqrarg*dsqrarg)
static
double
dmaxarg1
,
dmaxarg2
;
#define DMAX(a,b) (dmaxarg1=(a),dmaxarg2=(b),(dmaxarg1) > (dmaxarg2) ?\
(dmaxarg1) : (dmaxarg2))
static
double
dminarg1
,
dminarg2
;
#define DMIN(a,b) (dminarg1=(a),dminarg2=(b),(dminarg1) < (dminarg2) ?\
(dminarg1) : (dminarg2))
static
float
maxarg1
,
maxarg2
;
#define FMAX(a,b) (maxarg1=(a),maxarg2=(b),(maxarg1) > (maxarg2) ?\
(maxarg1) : (maxarg2))
static
float
minarg1
,
minarg2
;
#define FMIN(a,b) (minarg1=(a),minarg2=(b),(minarg1) < (minarg2) ?\
(minarg1) : (minarg2))
static
long
lmaxarg1
,
lmaxarg2
;
#define LMAX(a,b) (lmaxarg1=(a),lmaxarg2=(b),(lmaxarg1) > (lmaxarg2) ?\
(lmaxarg1) : (lmaxarg2))
static
long
lminarg1
,
lminarg2
;
#define LMIN(a,b) (lminarg1=(a),lminarg2=(b),(lminarg1) < (lminarg2) ?\
(lminarg1) : (lminarg2))
static
int
imaxarg1
,
imaxarg2
;
#define IMAX(a,b) (imaxarg1=(a),imaxarg2=(b),(imaxarg1) > (imaxarg2) ?\
(imaxarg1) : (imaxarg2))
static
int
iminarg1
,
iminarg2
;
#define IMIN(a,b) (iminarg1=(a),iminarg2=(b),(iminarg1) < (iminarg2) ?\
(iminarg1) : (iminarg2))
#define SIGN(a,b) ((b) >= 0.0 ? fabs(a) : -fabs(a))
void
nrerror
(
char
error_text
[]);
float
*
vector
(
long
nl
,
long
nh
);
int
*
ivector
(
long
nl
,
long
nh
);
unsigned
char
*
cvector
(
long
nl
,
long
nh
);
unsigned
long
*
lvector
(
long
nl
,
long
nh
);
double
*
dvector
(
long
nl
,
long
nh
);
float
**
matrix
(
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
);
double
**
dmatrix
(
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
);
int
**
imatrix
(
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
);
float
**
submatrix
(
float
**
a
,
long
oldrl
,
long
oldrh
,
long
oldcl
,
long
oldch
,
long
newrl
,
long
newcl
);
float
**
convert_matrix
(
float
*
a
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
);
float
***
f3tensor
(
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
,
long
ndl
,
long
ndh
);
void
free_vector
(
float
*
v
,
long
nl
,
long
nh
);
void
free_ivector
(
int
*
v
,
long
nl
,
long
nh
);
void
free_cvector
(
unsigned
char
*
v
,
long
nl
,
long
nh
);
void
free_lvector
(
unsigned
long
*
v
,
long
nl
,
long
nh
);
void
free_dvector
(
double
*
v
,
long
nl
,
long
nh
);
void
free_matrix
(
float
**
m
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
);
void
free_dmatrix
(
double
**
m
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
);
void
free_imatrix
(
int
**
m
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
);
void
free_submatrix
(
float
**
b
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
);
void
free_convert_matrix
(
float
**
b
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
);
void
free_f3tensor
(
float
***
t
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
,
long
ndl
,
long
ndh
);
int
***
i3tensor
(
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
,
long
ndl
,
long
ndh
);
void
free_i3tensor
(
int
***
t
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
,
long
ndl
,
long
ndh
);
unsigned
char
***
b3tensor
(
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
,
long
ndl
,
long
ndh
);
void
free_b3tensor
(
unsigned
char
***
t
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
,
long
ndl
,
long
ndh
);
double
***
d3tensor
(
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
,
long
ndl
,
long
ndh
);
void
free_d3tensor
(
double
***
t
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
,
long
ndl
,
long
ndh
);
unsigned
char
**
cmatrix
(
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
);
void
free_cmatrix
(
unsigned
char
**
m
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
);
#endif
/* _NR_UTILS_H_ */
ObservationSim/PSF/PSFInterp/libCentroid/nrutil.o
0 → 100644
View file @
29ac5666
File added
ObservationSim/PSF/PSFInterp/libCentroid/test/testGaussian.py
0 → 100644
View file @
29ac5666
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
ctypes
import
galsim
libCentroid
=
ctypes
.
CDLL
(
'../libCentroid.so'
)
# CDLL加载库
print
(
'load libCenroid'
)
libCentroid
.
centroidWgt
.
argtypes
=
[
ctypes
.
POINTER
(
ctypes
.
c_float
),
ctypes
.
c_int
,
ctypes
.
c_int
,
ctypes
.
POINTER
(
ctypes
.
c_double
)]
IMAGE_WIDTH
=
180
IMAGE_HEIGHT
=
180
dx
=
0.275
dy
=-
0.393
center_x
=
90
+
dx
center_y
=
90
+
dy
R
=
np
.
sqrt
(
center_x
**
2
+
center_y
**
2
)
Gauss_map
=
np
.
zeros
((
IMAGE_HEIGHT
,
IMAGE_WIDTH
))
for
i
in
range
(
IMAGE_HEIGHT
):
for
j
in
range
(
IMAGE_WIDTH
):
dis
=
(
i
-
center_y
)
**
2
+
(
j
-
center_x
)
**
2
Gauss_map
[
i
,
j
]
=
np
.
exp
(
-
0.5
*
dis
/
R
)
ymap
=
galsim
.
InterpolatedImage
(
galsim
.
ImageF
(
Gauss_map
),
scale
=
0.01
)
zmap
=
ymap
#.shear(g1 = 0.15, g2=0.27) #using shear
Gauss_map
=
zmap
.
drawImage
(
nx
=
180
,
ny
=
180
,
scale
=
0.01
).
array
fig
=
plt
.
figure
(
figsize
=
(
5
,
5
))
plt
.
imshow
(
Gauss_map
,
origin
=
'lower'
)
imx
=
Gauss_map
/
np
.
sum
(
Gauss_map
)
ny
,
nx
=
imx
.
shape
print
(
nx
,
ny
,
np
.
max
(
imx
))
nn
=
nx
*
ny
arr
=
(
ctypes
.
c_float
*
nn
)()
arr
[:]
=
imx
.
reshape
(
nn
)
para
=
(
ctypes
.
c_double
*
10
)()
libCentroid
.
centroidWgt
(
arr
,
ny
,
nx
,
para
)
print
(
'haha'
)
print
(
para
[
0
:
5
])
cx
=
para
[
3
]
cy
=
para
[
4
]
print
(
'{:}'
.
format
(
cx
),
'{:}'
.
format
(
cy
))
from
scipy
import
ndimage
cx
,
cy
=
ndimage
.
center_of_mass
(
imx
)
print
(
'center_of_mass:'
,
cx
,
cy
)
plt
.
plot
(
para
[
4
],
para
[
3
],
'bx'
,
ms
=
15
)
plt
.
plot
(
cy
,
cx
,
'r+'
,
ms
=
15
)
plt
.
annotate
(
'dx,dy:'
,
[
10
,
170
],
color
=
'w'
)
plt
.
annotate
(
'{:8.5}, {:8.5}'
.
format
(
dx
,
dy
),
[
10
,
160
],
color
=
'w'
)
plt
.
annotate
(
'cx, cy:'
,
[
10
,
150
],
color
=
'w'
)
plt
.
annotate
(
'{:0<8.5}, {:0<8.5}'
.
format
(
center_x
,
center_y
),
[
10
,
140
],
color
=
'w'
)
plt
.
annotate
(
'{:0<8.5}, {:0<8.5}'
.
format
(
para
[
4
],
para
[
3
]),
[
10
,
130
],
color
=
'w'
)
plt
.
annotate
(
'{:0<8.5}, {:0<8.5}'
.
format
(
cy
,
cx
),
[
10
,
120
],
color
=
'w'
)
plt
.
show
()
ObservationSim/PSF/PSFInterp/libCentroid/test/testPSFcentroid.py
0 → 100644
View file @
29ac5666
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
ctypes
import
galsim
libCentroid
=
ctypes
.
CDLL
(
'../libCentroid.so'
)
# CDLL加载库
print
(
'load libCenroid'
)
libCentroid
.
centroidWgt
.
argtypes
=
[
ctypes
.
POINTER
(
ctypes
.
c_float
),
ctypes
.
c_int
,
ctypes
.
c_int
,
ctypes
.
POINTER
(
ctypes
.
c_double
)]
libCentroid
.
imSplint
.
argtypes
=
[
ctypes
.
POINTER
(
ctypes
.
c_float
),
ctypes
.
c_int
,
ctypes
.
c_int
,
ctypes
.
POINTER
(
ctypes
.
c_double
),
ctypes
.
c_int
,
ctypes
.
c_int
,
ctypes
.
POINTER
(
ctypes
.
c_float
)]
from
scipy.io
import
loadmat
data
=
loadmat
(
'/Users/chengliangwei/csstPSFdata/CSSOS_psf_ciomp/ccd20/wave_1/5_psf_array/psf_10.mat'
)
imx
=
data
[
'psf'
]
imx
=
imx
/
np
.
sum
(
imx
)
ny
,
nx
=
imx
.
shape
print
(
nx
,
ny
)
#imx centroid
nn
=
nx
*
ny
arr
=
(
ctypes
.
c_float
*
nn
)()
arr
[:]
=
imx
.
reshape
(
nn
)
para
=
(
ctypes
.
c_double
*
10
)()
libCentroid
.
centroidWgt
(
arr
,
ny
,
nx
,
para
)
imx_cx
=
para
[
3
]
imx_cy
=
para
[
4
]
#imx -> imy
nxt
=
nyt
=
160
nn
=
nxt
*
nyt
yat
=
(
ctypes
.
c_float
*
nn
)()
libCentroid
.
imSplint
(
arr
,
ny
,
nx
,
para
,
nxt
,
nyt
,
yat
)
imy
=
np
.
array
(
yat
[:]).
reshape
([
nxt
,
nyt
])
#imy centroid
libCentroid
.
centroidWgt
(
yat
,
nyt
,
nxt
,
para
)
imy_cx
=
para
[
3
]
imy_cy
=
para
[
4
]
#plot check
fig
=
plt
.
figure
(
figsize
=
(
12
,
6
))
##imx_plot
ax
=
plt
.
subplot
(
1
,
2
,
1
)
cpix
=
int
(
nx
/
2
)
dpix
=
10
plt
.
imshow
(
imx
[
cpix
-
dpix
:
cpix
+
dpix
,
cpix
-
dpix
:
cpix
+
dpix
],
origin
=
'lower'
)
plt
.
plot
(
imx_cy
-
cpix
+
dpix
,
imx_cx
-
cpix
+
dpix
,
'bx'
,
ms
=
20
)
from
scipy
import
ndimage
cx
,
cy
=
ndimage
.
center_of_mass
(
imx
)
plt
.
plot
(
cy
-
cpix
+
dpix
,
cx
-
cpix
+
dpix
,
'r+'
,
ms
=
20
)
maxIndx
=
np
.
argmax
(
imx
)
maxIndx
=
np
.
unravel_index
(
maxIndx
,
np
.
array
(
imx
).
shape
)
imgMaxPix_x
=
maxIndx
[
1
]
imgMaxPix_y
=
maxIndx
[
0
]
apSizeInPix
=
23
imgT
=
np
.
zeros_like
(
imx
)
imgT
[
imgMaxPix_y
-
apSizeInPix
:
imgMaxPix_y
+
apSizeInPix
+
1
,
imgMaxPix_x
-
apSizeInPix
:
imgMaxPix_x
+
apSizeInPix
+
1
]
=
\
imx
[
imgMaxPix_y
-
apSizeInPix
:
imgMaxPix_y
+
apSizeInPix
+
1
,
imgMaxPix_x
-
apSizeInPix
:
imgMaxPix_x
+
apSizeInPix
+
1
]
cx
,
cy
=
ndimage
.
center_of_mass
(
imgT
)
plt
.
plot
(
cy
-
cpix
+
dpix
,
cx
-
cpix
+
dpix
,
'b+'
,
ms
=
15
)
##imy_plot
ax
=
plt
.
subplot
(
1
,
2
,
2
)
cpix
=
int
(
nxt
/
2
)
dpix
=
10
plt
.
imshow
(
imy
[
cpix
-
dpix
:
cpix
+
dpix
,
cpix
-
dpix
:
cpix
+
dpix
],
origin
=
'lower'
)
plt
.
plot
(
imy_cy
-
cpix
+
dpix
,
imy_cx
-
cpix
+
dpix
,
'bx'
,
ms
=
20
)
plt
.
plot
([
dpix
,
dpix
],[
0
,
dpix
],
'w:'
)
plt
.
plot
([
0
,
dpix
],[
dpix
,
dpix
],
'w:'
)
cx
,
cy
=
ndimage
.
center_of_mass
(
imy
)
plt
.
plot
(
cy
-
cpix
+
dpix
,
cx
-
cpix
+
dpix
,
'r+'
,
ms
=
20
)
maxIndx
=
np
.
argmax
(
imy
)
maxIndx
=
np
.
unravel_index
(
maxIndx
,
np
.
array
(
imy
).
shape
)
imgMaxPix_x
=
maxIndx
[
1
]
imgMaxPix_y
=
maxIndx
[
0
]
apSizeInPix
=
23
imgT
=
np
.
zeros_like
(
imy
)
imgT
[
imgMaxPix_y
-
apSizeInPix
:
imgMaxPix_y
+
apSizeInPix
+
1
,
imgMaxPix_x
-
apSizeInPix
:
imgMaxPix_x
+
apSizeInPix
+
1
]
=
\
imy
[
imgMaxPix_y
-
apSizeInPix
:
imgMaxPix_y
+
apSizeInPix
+
1
,
imgMaxPix_x
-
apSizeInPix
:
imgMaxPix_x
+
apSizeInPix
+
1
]
cx
,
cy
=
ndimage
.
center_of_mass
(
imgT
)
plt
.
plot
(
cy
-
cpix
+
dpix
,
cx
-
cpix
+
dpix
,
'b+'
,
ms
=
15
)
plt
.
show
()
ObservationSim/PSF/PSFInterp/libCentroid/test/tt.py
0 → 100644
View file @
29ac5666
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
ctypes
import
galsim
libCentroid
=
ctypes
.
CDLL
(
'../libCentroid.so'
)
# CDLL加载库
print
(
'load libCenroid'
)
libCentroid
.
centroidWgt
.
argtypes
=
[
ctypes
.
POINTER
(
ctypes
.
c_float
),
ctypes
.
c_int
,
ctypes
.
c_int
,
ctypes
.
POINTER
(
ctypes
.
c_double
)]
'''
IMAGE_WIDTH = 180
IMAGE_HEIGHT = 180
dx = 0.#275
dy =-0.#393
center_x = 90 +dx #89.5 #IMAGE_WIDTH/2 -0.
center_y = 90 +dy #89.5 #IMAGE_HEIGHT/2+0.
R = np.sqrt(center_x**2 + center_y**2)
Gauss_map = np.zeros((IMAGE_HEIGHT, IMAGE_WIDTH))
for i in range(IMAGE_HEIGHT):
for j in range(IMAGE_WIDTH):
dis = (i-center_y)**2+(j-center_x)**2
Gauss_map[i, j] = np.exp(-0.5*dis/R)
ymap = galsim.InterpolatedImage(galsim.ImageF(Gauss_map), scale=0.01)
zmap = ymap.shear(g1 = 0.15, g2=0.27)
Gauss_map = zmap.drawImage(nx = 180, ny = 180, scale=0.01).array
fig=plt.figure(figsize=(5,5))
plt.imshow(Gauss_map, origin='lower')
imx = Gauss_map#/np.sum(Gauss_map)
ny,nx = imx.shape
print(nx, ny, np.max(imx))
nn = nx*ny
arr = (ctypes.c_float*nn)()
arr[:] = imx.reshape(nn)
para = (ctypes.c_double*10)()
libCentroid.centroidWgt(arr, ny, nx, para)
print('haha')
print(para[0:5])
cx = para[3]
cy = para[4]
print('{:}'.format(cx), '{:}'.format(cy))
from scipy import ndimage
cx, cy = ndimage.center_of_mass(imx)
print('center_of_mass:', cx, cy)
plt.plot(para[4], para[3], 'bx', ms = 15)
plt.plot(cy, cx, 'r+', ms = 15)
plt.annotate('dx,dy:', [10, 170], color='w')
plt.annotate('{:8.5}, {:8.5}'.format(dx, dy), [10, 160], color='w')
plt.annotate('cx, cy:', [10, 150], color='w')
plt.annotate('{:0<8.5}, {:0<8.5}'.format(center_x, center_y), [10, 140], color='w')
plt.annotate('{:0<8.5}, {:0<8.5}'.format(para[4], para[3]), [10, 130], color='w')
plt.annotate('{:0<8.5}, {:0<8.5}'.format(cy, cx), [10, 120], color='w')
'''
from
scipy.io
import
loadmat
data
=
loadmat
(
'/Users/chengliangwei/csstPSFdata/CSSOS_psf_ciomp/ccd13/wave_1/5_psf_array/psf_10.mat'
)
#plt.imshow(data['psf'])
#plt.show()
imx
=
data
[
'psf'
]
imx
=
imx
/
np
.
sum
(
imx
)
ny
,
nx
=
imx
.
shape
print
(
nx
,
ny
)
nn
=
nx
*
ny
arr
=
(
ctypes
.
c_float
*
nn
)()
arr
[:]
=
imx
.
reshape
(
nn
)
para
=
(
ctypes
.
c_double
*
10
)()
print
(
arr
[
0
:
10
])
#libCentroid.centroidWgt(arr, ny, nx, para)
nxt
=
nyt
=
160
nn
=
nxt
*
nyt
yat
=
(
ctypes
.
c_float
*
nn
)()
libCentroid
.
centroidWgt
(
arr
,
ny
,
nx
,
para
,
nxt
,
nyt
,
yat
)
mm
=
np
.
array
(
yat
[:]).
reshape
([
nxt
,
nyt
])
imx
=
mm
print
(
'haha'
)
print
(
para
[
0
:
5
])
cx
=
para
[
3
]
cy
=
para
[
4
]
print
(
cx
,
cy
)
fig
=
plt
.
figure
(
figsize
=
(
12
,
12
))
cpix
=
80
dpix
=
10
#plt.imshow(np.log10(imx[cpix-dpix:cpix+dpix, cpix-dpix:cpix+dpix]), origin='lower')
plt
.
imshow
(
imx
[
cpix
-
dpix
:
cpix
+
dpix
,
cpix
-
dpix
:
cpix
+
dpix
],
origin
=
'lower'
)
plt
.
plot
(
cy
-
cpix
+
dpix
,
cx
-
cpix
+
dpix
,
'bx'
,
ms
=
20
)
'''
from scipy import ndimage
cx, cy = ndimage.center_of_mass(imx)
print(cx, cy)
plt.plot(cy - cpix+dpix, cx - cpix+dpix, 'r+', ms = 20)
maxIndx = np.argmax(imx)
maxIndx = np.unravel_index(maxIndx, np.array(imx).shape)
imgMaxPix_x = maxIndx[1]
imgMaxPix_y = maxIndx[0]
apSizeInPix = 23
imgT = np.zeros_like(imx)
imgT[imgMaxPix_y-apSizeInPix:imgMaxPix_y+apSizeInPix+1,
imgMaxPix_x-apSizeInPix:imgMaxPix_x+apSizeInPix+1] =
\
imx[imgMaxPix_y-apSizeInPix:imgMaxPix_y+apSizeInPix+1,
imgMaxPix_x-apSizeInPix:imgMaxPix_x+apSizeInPix+1]
cx, cy = ndimage.center_of_mass(imgT)
print(cx, cy)
plt.plot(cy - cpix+dpix, cx - cpix+dpix, 'b+', ms = 15)
maxIndx = np.argmax(imx)
maxIndx = np.unravel_index(maxIndx, np.array(imx).shape)
imgMaxPix_x = maxIndx[1]
imgMaxPix_y = maxIndx[0]
apSizeInPix =5
imgT = np.zeros_like(imx)
imgT[imgMaxPix_y-apSizeInPix:imgMaxPix_y+apSizeInPix+1,
imgMaxPix_x-apSizeInPix:imgMaxPix_x+apSizeInPix+1] =
\
imx[imgMaxPix_y-apSizeInPix:imgMaxPix_y+apSizeInPix+1,
imgMaxPix_x-apSizeInPix:imgMaxPix_x+apSizeInPix+1]
cx, cy = ndimage.center_of_mass(imgT)
print(cx, cy)
plt.plot(cy - cpix+dpix, cx - cpix+dpix, 'm+', ms = 10)
print('maxPix:', imgMaxPix_x, imgMaxPix_y, imx[imgMaxPix_y, imgMaxPix_x])
'''
plt
.
show
()
ObservationSim/PSF/PSFInterp/libCentroid/test/ttc/Makefile
0 → 100644
View file @
29ac5666
#OPTS += -D
CC
=
gcc
OPTIMIZE
=
-fPIC
-g
-O3
#-Wall -wd981 #-wd1419 -wd810
#GSLI = -I/home/alex/opt/gsl/include
#GSLL = -L/home/alex/opt/gsl/lib -lgsl -lgslcblas
#FFTWI = -I/home/alex/opt/fftw/include
#FFTWL = -L/home/alex/opt/fftw/lib -lfftw3 -lfftw3f
#HDF5I = -I/home/alex/opt/hdf5/include
#HDF5L = -L/home/alex/opt/hdf5/lib -lhdf5_hl -lhdf5
#FITSI = -I/home/alex/opt/cfitsio/include
#FITSL = -L/home/alex/opt/cfitsio/lib -lcfitsio
#EXTRACFLAGS =
#EXTRACLIB =
CLINK
=
$(CC)
CFLAGS
=
$(OPTIMIZE)
#
$(EXTRACFLAGS)
$(OPTS)
CLIB
=
-lm
#
$(EXTRACLIB)
OBJS
=
centroidWgt.o nrutil.o
EXEC
=
centroid.X
all
:
$(EXEC)
$(EXEC)
:
$(OBJS)
$(CLINK)
$(CFLAGS)
-o
$@
$(OBJS)
$(CLIB)
$(OBJS)
:
nrutil.h Makefile
.PHONY
:
clean
clean
:
rm
-f
*
.o
$(EXEC)
ObservationSim/PSF/PSFInterp/libCentroid/test/ttc/centroid.X
0 → 100755
View file @
29ac5666
File added
ObservationSim/PSF/PSFInterp/libCentroid/test/ttc/centroidWgt.c
0 → 100644
View file @
29ac5666
#include
<math.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
"nrutil.h"
//y is the input image, nx and ny are the pixels along x and y axis;
//yt and residu are the required matrix for the function
//para contains the needed parameters: centx=para[3], centy=para[4]
void
star_gaus
(
float
**
y
,
int
nx
,
int
ny
,
double
*
para
);
void
main
()
{
int
i
,
j
;
int
IMAGE_WIDTH
,
IMAGE_HEIGHT
;
float
center_x
,
center_y
;
float
R
,
dis
;
float
**
Gauss_map
;
double
*
para
;
//double para[10];
IMAGE_WIDTH
=
180
;
IMAGE_HEIGHT
=
180
;
center_x
=
IMAGE_WIDTH
/
2
-
0
.;
center_y
=
IMAGE_HEIGHT
/
2
+
0
.;
R
=
sqrt
(
center_x
*
center_x
+
center_y
*
center_y
);
//Gauss_map = np.zeros((IMAGE_HEIGHT, IMAGE_WIDTH))
Gauss_map
=
matrix
(
0
,
IMAGE_HEIGHT
-
1
,
0
,
IMAGE_WIDTH
-
1
);
para
=
dvector
(
0
,
10
);
for
(
i
=
0
;
i
<
IMAGE_HEIGHT
;
i
++
)
{
for
(
j
=
0
;
j
<
IMAGE_WIDTH
;
j
++
)
{
//#dis = np.sqrt((i-center_y)**2+(j-center_x)**2)
dis
=
(
i
-
center_y
)
*
(
i
-
center_y
)
+
(
j
-
center_x
)
*
(
j
-
center_x
);
//dis = sqrt(dis);
Gauss_map
[
i
][
j
]
=
exp
(
-
0
.
5
*
dis
/
R
);
}
}
star_gaus
(
Gauss_map
,
IMAGE_HEIGHT
,
IMAGE_WIDTH
,
para
);
printf
(
"ok?
\n
"
);
printf
(
"para:%f %f
\n
"
,
para
[
3
],
para
[
4
]);
//free_matrix(Gauss_map,0,IMAGE_HEIGHT-1,0,IMAGE_WIDTH-1);
//free_dvector(para,0,4);
}
void
centroidWgt
(
float
*
y
,
int
nx
,
int
ny
,
double
*
para
)
{
int
i
,
j
,
k
;
float
**
yy
;
double
**
basef
;
double
**
coff
;
yy
=
matrix
(
0
,
nx
-
1
,
0
,
ny
-
1
);
for
(
i
=
0
;
i
<
nx
;
i
++
)
for
(
j
=
0
;
j
<
ny
;
j
++
)
{
k
=
j
+
i
*
nx
;
yy
[
i
][
j
]
=
y
[
k
];
}
star_gaus
(
yy
,
nx
,
ny
,
para
);
}
//void star_gaus(float **y,int nx,int ny,float **yt,float **residu,double *para)
void
star_gaus
(
float
**
y
,
int
nx
,
int
ny
,
double
*
para
)
{
void
gasfit_2D
(
double
**
x
,
double
*
y
,
int
np
,
double
*
para
,
double
bg0
,
int
fbg
);
double
**
xs
,
*
ys
,
ymax
;
int
i
,
j
,
np
,
npt
,
im
,
jm
,
**
xi
,
k
;
double
kc
,
bgc
,
sigmac
,
xc
,
yc
,
sigma2v
,
det
;
double
bg0
=
0
;
int
fbg
=
0
;
np
=
nx
*
ny
;
xs
=
dmatrix
(
0
,
np
-
1
,
0
,
1
);
ys
=
dvector
(
0
,
np
-
1
);
xi
=
imatrix
(
0
,
np
-
1
,
0
,
1
);
ymax
=
y
[
0
][
0
];
for
(
i
=
0
;
i
<
nx
;
i
++
)
for
(
j
=
0
;
j
<
ny
;
j
++
){
if
(
ymax
<
y
[
i
][
j
]){
ymax
=
y
[
i
][
j
];
im
=
i
;
jm
=
j
;}
}
printf
(
"x=%d,y=%d,ymax=%e
\n
"
,
im
,
jm
,
ymax
);
int
cutPix
;
cutPix
=
23
;
npt
=
0
;
for
(
i
=-
cutPix
;
i
<=
cutPix
;
i
++
){
for
(
j
=-
cutPix
;
j
<=
cutPix
;
j
++
){
xs
[
npt
][
0
]
=
xi
[
npt
][
0
]
=
i
+
im
;
xs
[
npt
][
1
]
=
xi
[
npt
][
1
]
=
j
+
jm
;
ys
[
npt
]
=
y
[
im
+
i
][
jm
+
j
];
npt
++
;
}
}
printf
(
"check:: %f %f %f %d
\n
"
,
ys
[
0
],
ys
[
10
],
ys
[
100
],
npt
);
gasfit_2D
(
xs
,
ys
,
npt
,
para
,
bg0
,
fbg
);
kc
=
para
[
0
];
sigmac
=
para
[
1
];
bgc
=
para
[
2
];
xc
=
para
[
3
];
yc
=
para
[
4
];
printf
(
"xc, yc: %f %f
\n
"
,
yc
,
xc
);
//printf("%e %e %e %e %e\n",kc,sigmac,bgc,xc,yc);
/*
sigma2v=-1./(2.*sigmac*sigmac);
for(i=0;i<nx;i++){
for(j=0;j<ny;j++){
det=DSQR(i-xc)+DSQR(j-yc);
yt[i][j]=kc*exp(det*sigma2v)+bgc;
residu[i][j]=y[i][j]-yt[i][j];
}
}
*/
free_dmatrix
(
xs
,
0
,
np
-
1
,
0
,
1
);
free_imatrix
(
xi
,
0
,
np
-
1
,
0
,
1
);
free_dvector
(
ys
,
0
,
np
-
1
);
}
void
gasfit_2D
(
double
**
x
,
double
*
y
,
int
np
,
double
*
para
,
double
bg0
,
int
fbg
)
{
void
search_2D
(
double
**
x
,
double
*
y
,
int
np
,
double
kc
,
double
kd
,
double
sigmac
,
double
sigmad
,
double
bgc
,
double
bgd
,
double
xc
,
double
xd
,
double
yc
,
double
yd
,
double
*
para
,
double
bg0
,
int
fbg
);
int
i
,
j
,
k
,
imax
=
0
,
isigma
;
double
ymax
,
ymin
,
kc
,
kd
,
sigmac
,
sigmad
,
bgc
,
bgd
,
ysigma
,
xc
,
yc
,
xd
,
yd
;
double
det
,
dett
;
ymin
=
ymax
=
y
[
imax
];
for
(
i
=
1
;
i
<
np
;
i
++
){
if
(
ymax
<
y
[
i
]){
imax
=
i
;
ymax
=
y
[
i
];}
if
(
ymin
>
y
[
i
])
ymin
=
y
[
i
];
}
//printf("ymax=%e,imax=%d\n",ymax,imax);
kc
=
ymax
;
kd
=
ymax
/
12
.;
det
=
ysigma
=
kc
*
exp
(
-
0
.
5
);
//printf("det=%e,kc=%e\n",det,kc);
for
(
i
=
0
;
i
<
np
;
i
++
){
dett
=
fabs
(
ysigma
-
y
[
i
]);
//printf("dett=%e,det=%e,i=%d\n",dett,det,i);
//if(dett<det && y[i]!=kc){det=dett;isigma=i;}
if
(
dett
<
det
){
det
=
dett
;
isigma
=
i
;}
}
xc
=
x
[
imax
][
0
];
yc
=
x
[
imax
][
1
];
printf
(
"isigma=%d,imax=%d
\n
"
,
isigma
,
imax
);
sigmac
=
sqrt
(
DSQR
(
xc
-
x
[
isigma
][
0
])
+
DSQR
(
yc
-
x
[
isigma
][
1
]))
*
1
.;
xd
=
yd
=
sigmac
*
0
.
25
;
sigmad
=
0
.
25
*
sigmac
;
bgc
=
0
.;
bgd
=
fabs
(
ymin
);
//printf("sigma=%e\n",sigmac);
for
(
i
=
0
;
i
<
4
;
i
++
){
printf
(
"i = %d
\n
"
,
i
);
//printf("%e %e %e %e %e k2=%e\n",kc,sigmac,bgc,xc,yc,para[5]);
search_2D
(
x
,
y
,
np
,
kc
,
kd
,
sigmac
,
sigmad
,
bgc
,
bgd
,
xc
,
xd
,
yc
,
yd
,
para
,
bg0
,
fbg
);
kd
*=
0
.
33
;
sigmad
*=
0
.
33
;
bgd
*=
0
.
33
;
xd
*=
0
.
33
;
yd
*=
0
.
33
;
kc
=
para
[
0
];
sigmac
=
para
[
1
];
bgc
=
para
[
2
];
xc
=
para
[
3
];
yc
=
para
[
4
];
}
if
(
fbg
==
0
)
para
[
2
]
=
bg0
;
}
void
search_2D
(
double
**
x
,
double
*
y
,
int
np
,
double
kc
,
double
kd
,
double
sigmac
,
double
sigmad
,
double
bgc
,
double
bgd
,
double
xc
,
double
xd
,
double
yc
,
double
yd
,
double
*
para
,
double
bg0
,
int
fbg
)
{
double
k
,
sigma
,
bg
,
k2
,
k20
,
sigma2v
,
det
,
xt
,
yt
;
int
i
,
j
,
l
,
m
,
p
,
q
;
sigma2v
=-
1
.
/
(
2
.
*
sigmac
*
sigmac
);
bg
=
bgc
;
k20
=
0
;
for
(
m
=
0
;
m
<
np
;
m
++
){
det
=
DSQR
(
x
[
m
][
0
]
-
xc
)
+
DSQR
(
x
[
m
][
1
]
-
yc
);
det
=
kc
*
exp
(
det
*
sigma2v
)
+
bgc
-
y
[
m
];
k20
+=
det
*
det
;
}
for
(
i
=-
4
;
i
<=
4
;
i
++
){
k
=
kc
+
i
*
kd
;
if
(
k
>
0
){
for
(
j
=-
4
;
j
<=
4
;
j
++
){
sigma
=
sigmac
+
j
*
sigmad
;
if
(
sigma
>
0
){
sigma2v
=-
1
.
/
(
2
.
*
sigma
*
sigma
);
for
(
p
=-
4
;
p
<=
4
;
p
++
){
xt
=
xc
+
p
*
xd
;
for
(
q
=-
4
;
q
<=
4
;
q
++
){
yt
=
yc
+
q
*
yd
;
k2
=
0
;
if
(
fbg
==
0
){
bg
=
bg0
;
for
(
m
=
0
;
m
<
np
;
m
++
){
det
=
DSQR
(
x
[
m
][
0
]
-
xt
)
+
DSQR
(
x
[
m
][
1
]
-
yt
);
det
=
k
*
exp
(
det
*
sigma2v
)
+
bg
-
y
[
m
];
k2
+=
det
*
det
;
}
}
else
{
for
(
l
=-
4
;
l
<=
4
;
l
++
){
bg
=
bgc
+
l
*
bgd
;
for
(
m
=
0
;
m
<
np
;
m
++
){
det
=
DSQR
(
x
[
m
][
0
]
-
xt
)
+
DSQR
(
x
[
m
][
1
]
-
yt
);
det
=
k
*
exp
(
det
*
sigma2v
)
+
bg
-
y
[
m
];
k2
+=
det
*
det
;
}
}
}
//printf("k20=%e k2=%e\n",k20,k2);
if
(
k2
<=
k20
){
k20
=
k2
;
para
[
5
]
=
k2
;
para
[
0
]
=
k
;
para
[
1
]
=
sigma
;
para
[
2
]
=
bg
;
para
[
3
]
=
xt
;
para
[
4
]
=
yt
;}
}
}
}
}
}
}
}
ObservationSim/PSF/PSFInterp/libCentroid/test/ttc/centroidWgt.o
0 → 100644
View file @
29ac5666
File added
ObservationSim/PSF/PSFInterp/libCentroid/test/ttc/nrutil.c
0 → 100644
View file @
29ac5666
#if defined(__STDC__) || defined(ANSI) || defined(NRANSI)
/* ANSI */
#include
<stdio.h>
#include
<stddef.h>
#include
<stdlib.h>
#define NR_END 1
#define FREE_ARG char*
void
nrerror
(
char
error_text
[])
/* Numerical Recipes standard error handler */
{
fprintf
(
stderr
,
"Numerical Recipes run-time error...
\n
"
);
fprintf
(
stderr
,
"%s
\n
"
,
error_text
);
fprintf
(
stderr
,
"...now exiting to system...
\n
"
);
exit
(
1
);
}
float
*
vector
(
long
nl
,
long
nh
)
/* allocate a float vector with subscript range v[nl..nh] */
{
float
*
v
;
v
=
(
float
*
)
malloc
((
size_t
)
((
nh
-
nl
+
1
+
NR_END
)
*
sizeof
(
float
)));
if
(
!
v
)
nrerror
(
"allocation failure in vector()"
);
return
v
-
nl
+
NR_END
;
}
int
*
ivector
(
long
nl
,
long
nh
)
/* allocate an int vector with subscript range v[nl..nh] */
{
int
*
v
;
v
=
(
int
*
)
malloc
((
size_t
)
((
nh
-
nl
+
1
+
NR_END
)
*
sizeof
(
int
)));
if
(
!
v
)
nrerror
(
"allocation failure in ivector()"
);
return
v
-
nl
+
NR_END
;
}
unsigned
char
*
cvector
(
long
nl
,
long
nh
)
/* allocate an unsigned char vector with subscript range v[nl..nh] */
{
unsigned
char
*
v
;
v
=
(
unsigned
char
*
)
malloc
((
size_t
)
((
nh
-
nl
+
1
+
NR_END
)
*
sizeof
(
unsigned
char
)));
if
(
!
v
)
nrerror
(
"allocation failure in cvector()"
);
return
v
-
nl
+
NR_END
;
}
unsigned
long
*
lvector
(
long
nl
,
long
nh
)
/* allocate an unsigned long vector with subscript range v[nl..nh] */
{
unsigned
long
*
v
;
v
=
(
unsigned
long
*
)
malloc
((
size_t
)
((
nh
-
nl
+
1
+
NR_END
)
*
sizeof
(
long
)));
if
(
!
v
)
nrerror
(
"allocation failure in lvector()"
);
return
v
-
nl
+
NR_END
;
}
double
*
dvector
(
long
nl
,
long
nh
)
/* allocate a double vector with subscript range v[nl..nh] */
{
double
*
v
;
v
=
(
double
*
)
malloc
((
size_t
)
((
nh
-
nl
+
1
+
NR_END
)
*
sizeof
(
double
)));
if
(
!
v
)
nrerror
(
"allocation failure in dvector()"
);
return
v
-
nl
+
NR_END
;
}
float
**
matrix
(
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
)
/* allocate a float matrix with subscript range m[nrl..nrh][ncl..nch] */
{
long
i
,
nrow
=
nrh
-
nrl
+
1
,
ncol
=
nch
-
ncl
+
1
;
float
**
m
;
/* allocate pointers to rows */
m
=
(
float
**
)
malloc
((
size_t
)((
nrow
+
NR_END
)
*
sizeof
(
float
*
)));
if
(
!
m
)
nrerror
(
"allocation failure 1 in matrix()"
);
m
+=
NR_END
;
m
-=
nrl
;
/* allocate rows and set pointers to them */
m
[
nrl
]
=
(
float
*
)
malloc
((
size_t
)((
nrow
*
ncol
+
NR_END
)
*
sizeof
(
float
)));
if
(
!
m
[
nrl
])
nrerror
(
"allocation failure 2 in matrix()"
);
m
[
nrl
]
+=
NR_END
;
m
[
nrl
]
-=
ncl
;
for
(
i
=
nrl
+
1
;
i
<=
nrh
;
i
++
)
m
[
i
]
=
m
[
i
-
1
]
+
ncol
;
/* return pointer to array of pointers to rows */
return
m
;
}
double
**
dmatrix
(
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
)
/* allocate a double matrix with subscript range m[nrl..nrh][ncl..nch] */
{
long
i
,
nrow
=
nrh
-
nrl
+
1
,
ncol
=
nch
-
ncl
+
1
;
double
**
m
;
/* allocate pointers to rows */
m
=
(
double
**
)
malloc
((
size_t
)((
nrow
+
NR_END
)
*
sizeof
(
double
*
)));
if
(
!
m
)
nrerror
(
"allocation failure 1 in matrix()"
);
m
+=
NR_END
;
m
-=
nrl
;
/* allocate rows and set pointers to them */
m
[
nrl
]
=
(
double
*
)
malloc
((
size_t
)((
nrow
*
ncol
+
NR_END
)
*
sizeof
(
double
)));
if
(
!
m
[
nrl
])
nrerror
(
"allocation failure 2 in matrix()"
);
m
[
nrl
]
+=
NR_END
;
m
[
nrl
]
-=
ncl
;
for
(
i
=
nrl
+
1
;
i
<=
nrh
;
i
++
)
m
[
i
]
=
m
[
i
-
1
]
+
ncol
;
/* return pointer to array of pointers to rows */
return
m
;
}
int
**
imatrix
(
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
)
/* allocate a int matrix with subscript range m[nrl..nrh][ncl..nch] */
{
long
i
,
nrow
=
nrh
-
nrl
+
1
,
ncol
=
nch
-
ncl
+
1
;
int
**
m
;
/* allocate pointers to rows */
m
=
(
int
**
)
malloc
((
size_t
)((
nrow
+
NR_END
)
*
sizeof
(
int
*
)));
if
(
!
m
)
nrerror
(
"allocation failure 1 in matrix()"
);
m
+=
NR_END
;
m
-=
nrl
;
/* allocate rows and set pointers to them */
m
[
nrl
]
=
(
int
*
)
malloc
((
size_t
)((
nrow
*
ncol
+
NR_END
)
*
sizeof
(
int
)));
if
(
!
m
[
nrl
])
nrerror
(
"allocation failure 2 in matrix()"
);
m
[
nrl
]
+=
NR_END
;
m
[
nrl
]
-=
ncl
;
for
(
i
=
nrl
+
1
;
i
<=
nrh
;
i
++
)
m
[
i
]
=
m
[
i
-
1
]
+
ncol
;
/* return pointer to array of pointers to rows */
return
m
;
}
float
**
submatrix
(
float
**
a
,
long
oldrl
,
long
oldrh
,
long
oldcl
,
long
oldch
,
long
newrl
,
long
newcl
)
/* point a submatrix [newrl..][newcl..] to a[oldrl..oldrh][oldcl..oldch] */
{
long
i
,
j
,
nrow
=
oldrh
-
oldrl
+
1
,
ncol
=
oldcl
-
newcl
;
float
**
m
;
/* allocate array of pointers to rows */
m
=
(
float
**
)
malloc
((
size_t
)
((
nrow
+
NR_END
)
*
sizeof
(
float
*
)));
if
(
!
m
)
nrerror
(
"allocation failure in submatrix()"
);
m
+=
NR_END
;
m
-=
newrl
;
/* set pointers to rows */
for
(
i
=
oldrl
,
j
=
newrl
;
i
<=
oldrh
;
i
++
,
j
++
)
m
[
j
]
=
a
[
i
]
+
ncol
;
/* return pointer to array of pointers to rows */
return
m
;
}
float
**
convert_matrix
(
float
*
a
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
)
/* allocate a float matrix m[nrl..nrh][ncl..nch] that points to the matrix
declared in the standard C manner as a[nrow][ncol], where nrow=nrh-nrl+1
and ncol=nch-ncl+1. The routine should be called with the address
&a[0][0] as the first argument. */
{
long
i
,
j
,
nrow
=
nrh
-
nrl
+
1
,
ncol
=
nch
-
ncl
+
1
;
float
**
m
;
/* allocate pointers to rows */
m
=
(
float
**
)
malloc
((
size_t
)
((
nrow
+
NR_END
)
*
sizeof
(
float
*
)));
if
(
!
m
)
nrerror
(
"allocation failure in convert_matrix()"
);
m
+=
NR_END
;
m
-=
nrl
;
/* set pointers to rows */
m
[
nrl
]
=
a
-
ncl
;
for
(
i
=
1
,
j
=
nrl
+
1
;
i
<
nrow
;
i
++
,
j
++
)
m
[
j
]
=
m
[
j
-
1
]
+
ncol
;
/* return pointer to array of pointers to rows */
return
m
;
}
float
***
f3tensor
(
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
,
long
ndl
,
long
ndh
)
/* allocate a float 3tensor with range t[nrl..nrh][ncl..nch][ndl..ndh] */
{
long
i
,
j
,
nrow
=
nrh
-
nrl
+
1
,
ncol
=
nch
-
ncl
+
1
,
ndep
=
ndh
-
ndl
+
1
;
float
***
t
;
/* allocate pointers to pointers to rows */
t
=
(
float
***
)
malloc
((
size_t
)((
nrow
+
NR_END
)
*
sizeof
(
float
**
)));
if
(
!
t
)
nrerror
(
"allocation failure 1 in f3tensor()"
);
t
+=
NR_END
;
t
-=
nrl
;
/* allocate pointers to rows and set pointers to them */
t
[
nrl
]
=
(
float
**
)
malloc
((
size_t
)((
nrow
*
ncol
+
NR_END
)
*
sizeof
(
float
*
)));
if
(
!
t
[
nrl
])
nrerror
(
"allocation failure 2 in f3tensor()"
);
t
[
nrl
]
+=
NR_END
;
t
[
nrl
]
-=
ncl
;
/* allocate rows and set pointers to them */
t
[
nrl
][
ncl
]
=
(
float
*
)
malloc
((
size_t
)((
nrow
*
ncol
*
ndep
+
NR_END
)
*
sizeof
(
float
)));
if
(
!
t
[
nrl
][
ncl
])
nrerror
(
"allocation failure 3 in f3tensor()"
);
t
[
nrl
][
ncl
]
+=
NR_END
;
t
[
nrl
][
ncl
]
-=
ndl
;
for
(
j
=
ncl
+
1
;
j
<=
nch
;
j
++
)
t
[
nrl
][
j
]
=
t
[
nrl
][
j
-
1
]
+
ndep
;
for
(
i
=
nrl
+
1
;
i
<=
nrh
;
i
++
)
{
t
[
i
]
=
t
[
i
-
1
]
+
ncol
;
t
[
i
][
ncl
]
=
t
[
i
-
1
][
ncl
]
+
ncol
*
ndep
;
for
(
j
=
ncl
+
1
;
j
<=
nch
;
j
++
)
t
[
i
][
j
]
=
t
[
i
][
j
-
1
]
+
ndep
;
}
/* return pointer to array of pointers to rows */
return
t
;
}
double
***
d3tensor
(
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
,
long
ndl
,
long
ndh
)
/* allocate a double 3tensor with range t[nrl..nrh][ncl..nch][ndl..ndh] */
{
long
i
,
j
,
nrow
=
nrh
-
nrl
+
1
,
ncol
=
nch
-
ncl
+
1
,
ndep
=
ndh
-
ndl
+
1
;
double
***
t
;
/* allocate pointers to pointers to rows */
t
=
(
double
***
)
malloc
((
size_t
)((
nrow
+
NR_END
)
*
sizeof
(
double
**
)));
if
(
!
t
)
nrerror
(
"allocation failure 1 in f3tensor()"
);
t
+=
NR_END
;
t
-=
nrl
;
/* allocate pointers to rows and set pointers to them */
t
[
nrl
]
=
(
double
**
)
malloc
((
size_t
)((
nrow
*
ncol
+
NR_END
)
*
sizeof
(
double
*
)));
if
(
!
t
[
nrl
])
nrerror
(
"allocation failure 2 in f3tensor()"
);
t
[
nrl
]
+=
NR_END
;
t
[
nrl
]
-=
ncl
;
/* allocate rows and set pointers to them */
t
[
nrl
][
ncl
]
=
(
double
*
)
malloc
((
size_t
)((
nrow
*
ncol
*
ndep
+
NR_END
)
*
sizeof
(
double
)));
if
(
!
t
[
nrl
][
ncl
])
nrerror
(
"allocation failure 3 in f3tensor()"
);
t
[
nrl
][
ncl
]
+=
NR_END
;
t
[
nrl
][
ncl
]
-=
ndl
;
for
(
j
=
ncl
+
1
;
j
<=
nch
;
j
++
)
t
[
nrl
][
j
]
=
t
[
nrl
][
j
-
1
]
+
ndep
;
for
(
i
=
nrl
+
1
;
i
<=
nrh
;
i
++
)
{
t
[
i
]
=
t
[
i
-
1
]
+
ncol
;
t
[
i
][
ncl
]
=
t
[
i
-
1
][
ncl
]
+
ncol
*
ndep
;
for
(
j
=
ncl
+
1
;
j
<=
nch
;
j
++
)
t
[
i
][
j
]
=
t
[
i
][
j
-
1
]
+
ndep
;
}
/* return pointer to array of pointers to rows */
return
t
;
}
unsigned
char
**
cmatrix
(
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
)
/* allocate a int matrix with subscript range m[nrl..nrh][ncl..nch] */
{
long
i
,
nrow
=
nrh
-
nrl
+
1
,
ncol
=
nch
-
ncl
+
1
;
unsigned
char
**
m
;
/* allocate pointers to rows */
m
=
(
unsigned
char
**
)
malloc
((
size_t
)((
nrow
+
NR_END
)
*
sizeof
(
unsigned
char
*
)));
if
(
!
m
)
nrerror
(
"allocation failure 1 in matrix()"
);
m
+=
NR_END
;
m
-=
nrl
;
/* allocate rows and set pointers to them */
m
[
nrl
]
=
(
unsigned
char
*
)
malloc
((
size_t
)((
nrow
*
ncol
+
NR_END
)
*
sizeof
(
unsigned
char
)));
if
(
!
m
[
nrl
])
nrerror
(
"allocation failure 2 in matrix()"
);
m
[
nrl
]
+=
NR_END
;
m
[
nrl
]
-=
ncl
;
for
(
i
=
nrl
+
1
;
i
<=
nrh
;
i
++
)
m
[
i
]
=
m
[
i
-
1
]
+
ncol
;
/* return pointer to array of pointers to rows */
return
m
;
}
void
free_vector
(
float
*
v
,
long
nl
,
long
nh
)
/* free a float vector allocated with vector() */
{
free
((
FREE_ARG
)
(
v
+
nl
-
NR_END
));
}
void
free_ivector
(
int
*
v
,
long
nl
,
long
nh
)
/* free an int vector allocated with ivector() */
{
free
((
FREE_ARG
)
(
v
+
nl
-
NR_END
));
}
void
free_cvector
(
unsigned
char
*
v
,
long
nl
,
long
nh
)
/* free an unsigned char vector allocated with cvector() */
{
free
((
FREE_ARG
)
(
v
+
nl
-
NR_END
));
}
void
free_lvector
(
unsigned
long
*
v
,
long
nl
,
long
nh
)
/* free an unsigned long vector allocated with lvector() */
{
free
((
FREE_ARG
)
(
v
+
nl
-
NR_END
));
}
void
free_dvector
(
double
*
v
,
long
nl
,
long
nh
)
/* free a double vector allocated with dvector() */
{
free
((
FREE_ARG
)
(
v
+
nl
-
NR_END
));
}
void
free_matrix
(
float
**
m
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
)
/* free a float matrix allocated by matrix() */
{
free
((
FREE_ARG
)
(
m
[
nrl
]
+
ncl
-
NR_END
));
free
((
FREE_ARG
)
(
m
+
nrl
-
NR_END
));
}
void
free_dmatrix
(
double
**
m
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
)
/* free a double matrix allocated by dmatrix() */
{
free
((
FREE_ARG
)
(
m
[
nrl
]
+
ncl
-
NR_END
));
free
((
FREE_ARG
)
(
m
+
nrl
-
NR_END
));
}
void
free_imatrix
(
int
**
m
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
)
/* free an int matrix allocated by imatrix() */
{
free
((
FREE_ARG
)
(
m
[
nrl
]
+
ncl
-
NR_END
));
free
((
FREE_ARG
)
(
m
+
nrl
-
NR_END
));
}
void
free_submatrix
(
float
**
b
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
)
/* free a submatrix allocated by submatrix() */
{
free
((
FREE_ARG
)
(
b
+
nrl
-
NR_END
));
}
void
free_convert_matrix
(
float
**
b
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
)
/* free a matrix allocated by convert_matrix() */
{
free
((
FREE_ARG
)
(
b
+
nrl
-
NR_END
));
}
void
free_f3tensor
(
float
***
t
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
,
long
ndl
,
long
ndh
)
/* free a float f3tensor allocated by f3tensor() */
{
free
((
FREE_ARG
)
(
t
[
nrl
][
ncl
]
+
ndl
-
NR_END
));
free
((
FREE_ARG
)
(
t
[
nrl
]
+
ncl
-
NR_END
));
free
((
FREE_ARG
)
(
t
+
nrl
-
NR_END
));
}
void
free_d3tensor
(
double
***
t
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
,
long
ndl
,
long
ndh
)
/* free a double f3tensor allocated by f3tensor() */
{
free
((
FREE_ARG
)
(
t
[
nrl
][
ncl
]
+
ndl
-
NR_END
));
free
((
FREE_ARG
)
(
t
[
nrl
]
+
ncl
-
NR_END
));
free
((
FREE_ARG
)
(
t
+
nrl
-
NR_END
));
}
void
free_cmatrix
(
unsigned
char
**
m
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
)
/* free a character matrix allocated by matrix() */
{
free
((
FREE_ARG
)
(
m
[
nrl
]
+
ncl
-
NR_END
));
free
((
FREE_ARG
)
(
m
+
nrl
-
NR_END
));
}
#else
/* ANSI */
/* traditional - K&R */
#include
<stdio.h>
#define NR_END 1
#define FREE_ARG char*
void
nrerror
(
error_text
)
char
error_text
[];
/* Numerical Recipes standard error handler */
{
void
exit
();
fprintf
(
stderr
,
"Numerical Recipes run-time error...
\n
"
);
fprintf
(
stderr
,
"%s
\n
"
,
error_text
);
fprintf
(
stderr
,
"...now exiting to system...
\n
"
);
exit
(
1
);
}
float
*
vector
(
nl
,
nh
)
long
nh
,
nl
;
/* allocate a float vector with subscript range v[nl..nh] */
{
float
*
v
;
v
=
(
float
*
)
malloc
((
unsigned
int
)
((
nh
-
nl
+
1
+
NR_END
)
*
sizeof
(
float
)));
if
(
!
v
)
nrerror
(
"allocation failure in vector()"
);
return
v
-
nl
+
NR_END
;
}
int
*
ivector
(
nl
,
nh
)
long
nh
,
nl
;
/* allocate an int vector with subscript range v[nl..nh] */
{
int
*
v
;
v
=
(
int
*
)
malloc
((
unsigned
int
)
((
nh
-
nl
+
1
+
NR_END
)
*
sizeof
(
int
)));
if
(
!
v
)
nrerror
(
"allocation failure in ivector()"
);
return
v
-
nl
+
NR_END
;
}
unsigned
char
*
cvector
(
nl
,
nh
)
long
nh
,
nl
;
/* allocate an unsigned char vector with subscript range v[nl..nh] */
{
unsigned
char
*
v
;
v
=
(
unsigned
char
*
)
malloc
((
unsigned
int
)
((
nh
-
nl
+
1
+
NR_END
)
*
sizeof
(
unsigned
char
)));
if
(
!
v
)
nrerror
(
"allocation failure in cvector()"
);
return
v
-
nl
+
NR_END
;
}
unsigned
long
*
lvector
(
nl
,
nh
)
long
nh
,
nl
;
/* allocate an unsigned long vector with subscript range v[nl..nh] */
{
unsigned
long
*
v
;
v
=
(
unsigned
long
*
)
malloc
((
unsigned
int
)
((
nh
-
nl
+
1
+
NR_END
)
*
sizeof
(
long
)));
if
(
!
v
)
nrerror
(
"allocation failure in lvector()"
);
return
v
-
nl
+
NR_END
;
}
double
*
dvector
(
nl
,
nh
)
long
nh
,
nl
;
/* allocate a double vector with subscript range v[nl..nh] */
{
double
*
v
;
v
=
(
double
*
)
malloc
((
unsigned
int
)
((
nh
-
nl
+
1
+
NR_END
)
*
sizeof
(
double
)));
if
(
!
v
)
nrerror
(
"allocation failure in dvector()"
);
return
v
-
nl
+
NR_END
;
}
float
**
matrix
(
nrl
,
nrh
,
ncl
,
nch
)
long
nch
,
ncl
,
nrh
,
nrl
;
/* allocate a float matrix with subscript range m[nrl..nrh][ncl..nch] */
{
long
i
,
nrow
=
nrh
-
nrl
+
1
,
ncol
=
nch
-
ncl
+
1
;
float
**
m
;
/* allocate pointers to rows */
m
=
(
float
**
)
malloc
((
unsigned
int
)((
nrow
+
NR_END
)
*
sizeof
(
float
*
)));
if
(
!
m
)
nrerror
(
"allocation failure 1 in matrix()"
);
m
+=
NR_END
;
m
-=
nrl
;
/* allocate rows and set pointers to them */
m
[
nrl
]
=
(
float
*
)
malloc
((
unsigned
int
)((
nrow
*
ncol
+
NR_END
)
*
sizeof
(
float
)));
if
(
!
m
[
nrl
])
nrerror
(
"allocation failure 2 in matrix()"
);
m
[
nrl
]
+=
NR_END
;
m
[
nrl
]
-=
ncl
;
for
(
i
=
nrl
+
1
;
i
<=
nrh
;
i
++
)
m
[
i
]
=
m
[
i
-
1
]
+
ncol
;
/* return pointer to array of pointers to rows */
return
m
;
}
double
**
dmatrix
(
nrl
,
nrh
,
ncl
,
nch
)
long
nch
,
ncl
,
nrh
,
nrl
;
/* allocate a double matrix with subscript range m[nrl..nrh][ncl..nch] */
{
long
i
,
nrow
=
nrh
-
nrl
+
1
,
ncol
=
nch
-
ncl
+
1
;
double
**
m
;
/* allocate pointers to rows */
m
=
(
double
**
)
malloc
((
unsigned
int
)((
nrow
+
NR_END
)
*
sizeof
(
double
*
)));
if
(
!
m
)
nrerror
(
"allocation failure 1 in matrix()"
);
m
+=
NR_END
;
m
-=
nrl
;
/* allocate rows and set pointers to them */
m
[
nrl
]
=
(
double
*
)
malloc
((
unsigned
int
)((
nrow
*
ncol
+
NR_END
)
*
sizeof
(
double
)));
if
(
!
m
[
nrl
])
nrerror
(
"allocation failure 2 in matrix()"
);
m
[
nrl
]
+=
NR_END
;
m
[
nrl
]
-=
ncl
;
for
(
i
=
nrl
+
1
;
i
<=
nrh
;
i
++
)
m
[
i
]
=
m
[
i
-
1
]
+
ncol
;
/* return pointer to array of pointers to rows */
return
m
;
}
int
**
imatrix
(
nrl
,
nrh
,
ncl
,
nch
)
long
nch
,
ncl
,
nrh
,
nrl
;
/* allocate a int matrix with subscript range m[nrl..nrh][ncl..nch] */
{
long
i
,
nrow
=
nrh
-
nrl
+
1
,
ncol
=
nch
-
ncl
+
1
;
int
**
m
;
/* allocate pointers to rows */
m
=
(
int
**
)
malloc
((
unsigned
int
)((
nrow
+
NR_END
)
*
sizeof
(
int
*
)));
if
(
!
m
)
nrerror
(
"allocation failure 1 in matrix()"
);
m
+=
NR_END
;
m
-=
nrl
;
/* allocate rows and set pointers to them */
m
[
nrl
]
=
(
int
*
)
malloc
((
unsigned
int
)((
nrow
*
ncol
+
NR_END
)
*
sizeof
(
int
)));
if
(
!
m
[
nrl
])
nrerror
(
"allocation failure 2 in matrix()"
);
m
[
nrl
]
+=
NR_END
;
m
[
nrl
]
-=
ncl
;
for
(
i
=
nrl
+
1
;
i
<=
nrh
;
i
++
)
m
[
i
]
=
m
[
i
-
1
]
+
ncol
;
/* return pointer to array of pointers to rows */
return
m
;
}
float
**
submatrix
(
a
,
oldrl
,
oldrh
,
oldcl
,
oldch
,
newrl
,
newcl
)
float
**
a
;
long
newcl
,
newrl
,
oldch
,
oldcl
,
oldrh
,
oldrl
;
/* point a submatrix [newrl..][newcl..] to a[oldrl..oldrh][oldcl..oldch] */
{
long
i
,
j
,
nrow
=
oldrh
-
oldrl
+
1
,
ncol
=
oldcl
-
newcl
;
float
**
m
;
/* allocate array of pointers to rows */
m
=
(
float
**
)
malloc
((
unsigned
int
)
((
nrow
+
NR_END
)
*
sizeof
(
float
*
)));
if
(
!
m
)
nrerror
(
"allocation failure in submatrix()"
);
m
+=
NR_END
;
m
-=
newrl
;
/* set pointers to rows */
for
(
i
=
oldrl
,
j
=
newrl
;
i
<=
oldrh
;
i
++
,
j
++
)
m
[
j
]
=
a
[
i
]
+
ncol
;
/* return pointer to array of pointers to rows */
return
m
;
}
float
**
convert_matrix
(
a
,
nrl
,
nrh
,
ncl
,
nch
)
float
*
a
;
long
nch
,
ncl
,
nrh
,
nrl
;
/* allocate a float matrix m[nrl..nrh][ncl..nch] that points to the matrix
declared in the standard C manner as a[nrow][ncol], where nrow=nrh-nrl+1
and ncol=nch-ncl+1. The routine should be called with the address
&a[0][0] as the first argument. */
{
long
i
,
j
,
nrow
=
nrh
-
nrl
+
1
,
ncol
=
nch
-
ncl
+
1
;
float
**
m
;
/* allocate pointers to rows */
m
=
(
float
**
)
malloc
((
unsigned
int
)
((
nrow
+
NR_END
)
*
sizeof
(
float
*
)));
if
(
!
m
)
nrerror
(
"allocation failure in convert_matrix()"
);
m
+=
NR_END
;
m
-=
nrl
;
/* set pointers to rows */
m
[
nrl
]
=
a
-
ncl
;
for
(
i
=
1
,
j
=
nrl
+
1
;
i
<
nrow
;
i
++
,
j
++
)
m
[
j
]
=
m
[
j
-
1
]
+
ncol
;
/* return pointer to array of pointers to rows */
return
m
;
}
double
***
d3tensor
(
nrl
,
nrh
,
ncl
,
nch
,
ndl
,
ndh
)
long
nch
,
ncl
,
ndh
,
ndl
,
nrh
,
nrl
;
/* allocate a float 3tensor with range t[nrl..nrh][ncl..nch][ndl..ndh] */
{
long
i
,
j
,
nrow
=
nrh
-
nrl
+
1
,
ncol
=
nch
-
ncl
+
1
,
ndep
=
ndh
-
ndl
+
1
;
double
***
t
;
/* allocate pointers to pointers to rows */
t
=
(
double
***
)
malloc
((
unsigned
int
)((
nrow
+
NR_END
)
*
sizeof
(
double
**
)));
if
(
!
t
)
nrerror
(
"allocation failure 1 in f3tensor()"
);
t
+=
NR_END
;
t
-=
nrl
;
/* allocate pointers to rows and set pointers to them */
t
[
nrl
]
=
(
double
**
)
malloc
((
unsigned
int
)((
nrow
*
ncol
+
NR_END
)
*
sizeof
(
double
*
)));
if
(
!
t
[
nrl
])
nrerror
(
"allocation failure 2 in f3tensor()"
);
t
[
nrl
]
+=
NR_END
;
t
[
nrl
]
-=
ncl
;
/* allocate rows and set pointers to them */
t
[
nrl
][
ncl
]
=
(
double
*
)
malloc
((
unsigned
int
)((
nrow
*
ncol
*
ndep
+
NR_END
)
*
sizeof
(
double
)));
if
(
!
t
[
nrl
][
ncl
])
nrerror
(
"allocation failure 3 in f3tensor()"
);
t
[
nrl
][
ncl
]
+=
NR_END
;
t
[
nrl
][
ncl
]
-=
ndl
;
for
(
j
=
ncl
+
1
;
j
<=
nch
;
j
++
)
t
[
nrl
][
j
]
=
t
[
nrl
][
j
-
1
]
+
ndep
;
for
(
i
=
nrl
+
1
;
i
<=
nrh
;
i
++
)
{
t
[
i
]
=
t
[
i
-
1
]
+
ncol
;
t
[
i
][
ncl
]
=
t
[
i
-
1
][
ncl
]
+
ncol
*
ndep
;
for
(
j
=
ncl
+
1
;
j
<=
nch
;
j
++
)
t
[
i
][
j
]
=
t
[
i
][
j
-
1
]
+
ndep
;
}
/* return pointer to array of pointers to rows */
return
t
;
}
float
***
f3tensor
(
nrl
,
nrh
,
ncl
,
nch
,
ndl
,
ndh
)
long
nch
,
ncl
,
ndh
,
ndl
,
nrh
,
nrl
;
/* allocate a float 3tensor with range t[nrl..nrh][ncl..nch][ndl..ndh] */
{
long
i
,
j
,
nrow
=
nrh
-
nrl
+
1
,
ncol
=
nch
-
ncl
+
1
,
ndep
=
ndh
-
ndl
+
1
;
float
***
t
;
/* allocate pointers to pointers to rows */
t
=
(
float
***
)
malloc
((
unsigned
int
)((
nrow
+
NR_END
)
*
sizeof
(
float
**
)));
if
(
!
t
)
nrerror
(
"allocation failure 1 in f3tensor()"
);
t
+=
NR_END
;
t
-=
nrl
;
/* allocate pointers to rows and set pointers to them */
t
[
nrl
]
=
(
float
**
)
malloc
((
unsigned
int
)((
nrow
*
ncol
+
NR_END
)
*
sizeof
(
float
*
)));
if
(
!
t
[
nrl
])
nrerror
(
"allocation failure 2 in f3tensor()"
);
t
[
nrl
]
+=
NR_END
;
t
[
nrl
]
-=
ncl
;
/* allocate rows and set pointers to them */
t
[
nrl
][
ncl
]
=
(
float
*
)
malloc
((
unsigned
int
)((
nrow
*
ncol
*
ndep
+
NR_END
)
*
sizeof
(
float
)));
if
(
!
t
[
nrl
][
ncl
])
nrerror
(
"allocation failure 3 in f3tensor()"
);
t
[
nrl
][
ncl
]
+=
NR_END
;
t
[
nrl
][
ncl
]
-=
ndl
;
for
(
j
=
ncl
+
1
;
j
<=
nch
;
j
++
)
t
[
nrl
][
j
]
=
t
[
nrl
][
j
-
1
]
+
ndep
;
for
(
i
=
nrl
+
1
;
i
<=
nrh
;
i
++
)
{
t
[
i
]
=
t
[
i
-
1
]
+
ncol
;
t
[
i
][
ncl
]
=
t
[
i
-
1
][
ncl
]
+
ncol
*
ndep
;
for
(
j
=
ncl
+
1
;
j
<=
nch
;
j
++
)
t
[
i
][
j
]
=
t
[
i
][
j
-
1
]
+
ndep
;
}
/* return pointer to array of pointers to rows */
return
t
;
}
unsigned
char
**
cmatrix
(
nrl
,
nrh
,
ncl
,
nch
)
long
nch
,
ncl
,
nrh
,
nrl
;
/* allocate a int matrix with subscript range m[nrl..nrh][ncl..nch] */
{
long
i
,
nrow
=
nrh
-
nrl
+
1
,
ncol
=
nch
-
ncl
+
1
;
unsigned
char
**
m
;
/* allocate pointers to rows */
m
=
(
unsigned
char
**
)
malloc
((
unsigned
int
)((
nrow
+
NR_END
)
*
sizeof
(
unsigned
char
*
)));
if
(
!
m
)
nrerror
(
"allocation failure 1 in matrix()"
);
m
+=
NR_END
;
m
-=
nrl
;
/* allocate rows and set pointers to them */
m
[
nrl
]
=
(
unsigned
char
*
)
malloc
((
unsigned
int
)((
nrow
*
ncol
+
NR_END
)
*
sizeof
(
unsigned
char
)));
if
(
!
m
[
nrl
])
nrerror
(
"allocation failure 2 in matrix()"
);
m
[
nrl
]
+=
NR_END
;
m
[
nrl
]
-=
ncl
;
for
(
i
=
nrl
+
1
;
i
<=
nrh
;
i
++
)
m
[
i
]
=
m
[
i
-
1
]
+
ncol
;
/* return pointer to array of pointers to rows */
return
m
;
}
void
free_vector
(
v
,
nl
,
nh
)
float
*
v
;
long
nh
,
nl
;
/* free a float vector allocated with vector() */
{
free
((
FREE_ARG
)
(
v
+
nl
-
NR_END
));
}
void
free_ivector
(
v
,
nl
,
nh
)
int
*
v
;
long
nh
,
nl
;
/* free an int vector allocated with ivector() */
{
free
((
FREE_ARG
)
(
v
+
nl
-
NR_END
));
}
void
free_cvector
(
v
,
nl
,
nh
)
long
nh
,
nl
;
unsigned
char
*
v
;
/* free an unsigned char vector allocated with cvector() */
{
free
((
FREE_ARG
)
(
v
+
nl
-
NR_END
));
}
void
free_lvector
(
v
,
nl
,
nh
)
long
nh
,
nl
;
unsigned
long
*
v
;
/* free an unsigned long vector allocated with lvector() */
{
free
((
FREE_ARG
)
(
v
+
nl
-
NR_END
));
}
void
free_dvector
(
v
,
nl
,
nh
)
double
*
v
;
long
nh
,
nl
;
/* free a double vector allocated with dvector() */
{
free
((
FREE_ARG
)
(
v
+
nl
-
NR_END
));
}
void
free_matrix
(
m
,
nrl
,
nrh
,
ncl
,
nch
)
float
**
m
;
long
nch
,
ncl
,
nrh
,
nrl
;
/* free a float matrix allocated by matrix() */
{
free
((
FREE_ARG
)
(
m
[
nrl
]
+
ncl
-
NR_END
));
free
((
FREE_ARG
)
(
m
+
nrl
-
NR_END
));
}
void
free_dmatrix
(
m
,
nrl
,
nrh
,
ncl
,
nch
)
double
**
m
;
long
nch
,
ncl
,
nrh
,
nrl
;
/* free a double matrix allocated by dmatrix() */
{
free
((
FREE_ARG
)
(
m
[
nrl
]
+
ncl
-
NR_END
));
free
((
FREE_ARG
)
(
m
+
nrl
-
NR_END
));
}
void
free_imatrix
(
m
,
nrl
,
nrh
,
ncl
,
nch
)
int
**
m
;
long
nch
,
ncl
,
nrh
,
nrl
;
/* free an int matrix allocated by imatrix() */
{
free
((
FREE_ARG
)
(
m
[
nrl
]
+
ncl
-
NR_END
));
free
((
FREE_ARG
)
(
m
+
nrl
-
NR_END
));
}
void
free_submatrix
(
b
,
nrl
,
nrh
,
ncl
,
nch
)
float
**
b
;
long
nch
,
ncl
,
nrh
,
nrl
;
/* free a submatrix allocated by submatrix() */
{
free
((
FREE_ARG
)
(
b
+
nrl
-
NR_END
));
}
void
free_convert_matrix
(
b
,
nrl
,
nrh
,
ncl
,
nch
)
float
**
b
;
long
nch
,
ncl
,
nrh
,
nrl
;
/* free a matrix allocated by convert_matrix() */
{
free
((
FREE_ARG
)
(
b
+
nrl
-
NR_END
));
}
void
free_f3tensor
(
t
,
nrl
,
nrh
,
ncl
,
nch
,
ndl
,
ndh
)
float
***
t
;
long
nch
,
ncl
,
ndh
,
ndl
,
nrh
,
nrl
;
/* free a float f3tensor allocated by f3tensor() */
{
free
((
FREE_ARG
)
(
t
[
nrl
][
ncl
]
+
ndl
-
NR_END
));
free
((
FREE_ARG
)
(
t
[
nrl
]
+
ncl
-
NR_END
));
free
((
FREE_ARG
)
(
t
+
nrl
-
NR_END
));
}
void
free_d3tensor
(
t
,
nrl
,
nrh
,
ncl
,
nch
,
ndl
,
ndh
)
double
***
t
;
long
nch
,
ncl
,
ndh
,
ndl
,
nrh
,
nrl
;
/* free a float f3tensor allocated by f3tensor() */
{
free
((
FREE_ARG
)
(
t
[
nrl
][
ncl
]
+
ndl
-
NR_END
));
free
((
FREE_ARG
)
(
t
[
nrl
]
+
ncl
-
NR_END
));
free
((
FREE_ARG
)
(
t
+
nrl
-
NR_END
));
}
void
free_cmatrix
(
m
,
nrl
,
nrh
,
ncl
,
nch
)
unsigned
**
m
;
long
nch
,
ncl
,
nrh
,
nrl
;
/* free a double matrix allocated by dmatrix() */
{
free
((
FREE_ARG
)
(
m
[
nrl
]
+
ncl
-
NR_END
));
free
((
FREE_ARG
)
(
m
+
nrl
-
NR_END
));
}
#endif
/* ANSI */
ObservationSim/PSF/PSFInterp/libCentroid/test/ttc/nrutil.h
0 → 100644
View file @
29ac5666
/* CAUTION: This is the ANSI C (only) version of the Numerical Recipes
utility file nrutil.h. Do not confuse this file with the same-named
file nrutil.h that may be supplied in a 'misc' subdirectory.
*That* file is the one from the book, and contains both ANSI and
traditional K&R versions, along with #ifdef macros to select the
correct version. *This* file contains only ANSI C. */
#ifndef _NR_UTILS_H_
#define _NR_UTILS_H_
static
float
sqrarg
;
#define SQR(a) ((sqrarg=(a)) == 0.0 ? 0.0 : sqrarg*sqrarg)
static
double
dsqrarg
;
#define DSQR(a) ((dsqrarg=(a)) == 0.0 ? 0.0 : dsqrarg*dsqrarg)
static
double
dmaxarg1
,
dmaxarg2
;
#define DMAX(a,b) (dmaxarg1=(a),dmaxarg2=(b),(dmaxarg1) > (dmaxarg2) ?\
(dmaxarg1) : (dmaxarg2))
static
double
dminarg1
,
dminarg2
;
#define DMIN(a,b) (dminarg1=(a),dminarg2=(b),(dminarg1) < (dminarg2) ?\
(dminarg1) : (dminarg2))
static
float
maxarg1
,
maxarg2
;
#define FMAX(a,b) (maxarg1=(a),maxarg2=(b),(maxarg1) > (maxarg2) ?\
(maxarg1) : (maxarg2))
static
float
minarg1
,
minarg2
;
#define FMIN(a,b) (minarg1=(a),minarg2=(b),(minarg1) < (minarg2) ?\
(minarg1) : (minarg2))
static
long
lmaxarg1
,
lmaxarg2
;
#define LMAX(a,b) (lmaxarg1=(a),lmaxarg2=(b),(lmaxarg1) > (lmaxarg2) ?\
(lmaxarg1) : (lmaxarg2))
static
long
lminarg1
,
lminarg2
;
#define LMIN(a,b) (lminarg1=(a),lminarg2=(b),(lminarg1) < (lminarg2) ?\
(lminarg1) : (lminarg2))
static
int
imaxarg1
,
imaxarg2
;
#define IMAX(a,b) (imaxarg1=(a),imaxarg2=(b),(imaxarg1) > (imaxarg2) ?\
(imaxarg1) : (imaxarg2))
static
int
iminarg1
,
iminarg2
;
#define IMIN(a,b) (iminarg1=(a),iminarg2=(b),(iminarg1) < (iminarg2) ?\
(iminarg1) : (iminarg2))
#define SIGN(a,b) ((b) >= 0.0 ? fabs(a) : -fabs(a))
void
nrerror
(
char
error_text
[]);
float
*
vector
(
long
nl
,
long
nh
);
int
*
ivector
(
long
nl
,
long
nh
);
unsigned
char
*
cvector
(
long
nl
,
long
nh
);
unsigned
long
*
lvector
(
long
nl
,
long
nh
);
double
*
dvector
(
long
nl
,
long
nh
);
float
**
matrix
(
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
);
double
**
dmatrix
(
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
);
int
**
imatrix
(
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
);
float
**
submatrix
(
float
**
a
,
long
oldrl
,
long
oldrh
,
long
oldcl
,
long
oldch
,
long
newrl
,
long
newcl
);
float
**
convert_matrix
(
float
*
a
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
);
float
***
f3tensor
(
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
,
long
ndl
,
long
ndh
);
void
free_vector
(
float
*
v
,
long
nl
,
long
nh
);
void
free_ivector
(
int
*
v
,
long
nl
,
long
nh
);
void
free_cvector
(
unsigned
char
*
v
,
long
nl
,
long
nh
);
void
free_lvector
(
unsigned
long
*
v
,
long
nl
,
long
nh
);
void
free_dvector
(
double
*
v
,
long
nl
,
long
nh
);
void
free_matrix
(
float
**
m
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
);
void
free_dmatrix
(
double
**
m
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
);
void
free_imatrix
(
int
**
m
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
);
void
free_submatrix
(
float
**
b
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
);
void
free_convert_matrix
(
float
**
b
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
);
void
free_f3tensor
(
float
***
t
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
,
long
ndl
,
long
ndh
);
int
***
i3tensor
(
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
,
long
ndl
,
long
ndh
);
void
free_i3tensor
(
int
***
t
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
,
long
ndl
,
long
ndh
);
unsigned
char
***
b3tensor
(
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
,
long
ndl
,
long
ndh
);
void
free_b3tensor
(
unsigned
char
***
t
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
,
long
ndl
,
long
ndh
);
double
***
d3tensor
(
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
,
long
ndl
,
long
ndh
);
void
free_d3tensor
(
double
***
t
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
,
long
ndl
,
long
ndh
);
unsigned
char
**
cmatrix
(
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
);
void
free_cmatrix
(
unsigned
char
**
m
,
long
nrl
,
long
nrh
,
long
ncl
,
long
nch
);
#endif
/* _NR_UTILS_H_ */
ObservationSim/PSF/PSFInterp/libCentroid/test/ttc/nrutil.o
0 → 100644
View file @
29ac5666
File added
ObservationSim/PSF/PSFInterp/test/PSFMatsREE50.py
0 → 100644
View file @
29ac5666
import
sys
from
itertools
import
islice
import
mpi4py.MPI
as
MPI
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
matplotlib
as
mpl
mpl
.
use
(
'Agg'
)
import
scipy.io
#import xlrd
from
scipy
import
ndimage
sys
.
path
.
append
(
"/public/home/weichengliang/lnData/CSST_new_framwork/csstPSF_20210108"
)
import
PSFConfig
as
myConfig
import
PSFUtil
as
myUtil
NPSF
=
900
##############################
##############################
##############################
def
test_psfREE80
(
psfPath
,
ThisTask
,
NTasks
):
nccd
=
30
npsf
=
NPSF
npsfPerTasks
=
int
(
npsf
/
NTasks
)
iStart
=
0
+
npsfPerTasks
*
ThisTask
iEnd
=
npsfPerTasks
+
npsfPerTasks
*
ThisTask
if
ThisTask
==
NTasks
:
iEnd
=
npsf
CENPIXUSED
=
True
wvREE80
=
np
.
zeros
([
4
,
nccd
])
#psf in different waves-4
ttREE80
=
np
.
zeros
(
nccd
)
#stacked psf
for
iccd
in
range
(
1
,
nccd
+
1
):
psf_wvREE80
=
np
.
zeros
([
4
,
npsf
])
psf_ttREE80
=
np
.
zeros
(
npsf
)
#for ipsf in range(1, npsf+1):
for
ipsf
in
range
(
iStart
+
1
,
iEnd
+
1
):
psf4iwave
=
[]
for
iwave
in
range
(
1
,
5
):
if
ThisTask
==
0
:
print
(
'iccd-ipsf-iwave: {:} {:} {:}'
.
format
(
iccd
,
ipsf
,
iwave
),
end
=
'
\r
'
)
psfInfo
=
myConfig
.
LoadPSF
(
iccd
,
iwave
,
ipsf
,
psfPath
,
InputMaxPixelPos
=
True
,
PSFCentroidWgt
=
False
)
cenPix
=
None
if
CENPIXUSED
:
psfInfoX
=
myConfig
.
LoadPSF
(
iccd
,
iwave
,
ipsf
,
psfPath
,
InputMaxPixelPos
=
True
,
PSFCentroidWgt
=
True
)
deltX
=
psfInfoX
[
'centroid_x'
]
#in mm
deltY
=
psfInfoX
[
'centroid_y'
]
#in mm
pixsize
=
2.5
*
1e-3
#mm, will use binningPSF
cenPix_X
=
512
/
2
+
deltX
/
pixsize
cenPix_Y
=
512
/
2
+
deltY
/
pixsize
cenPix
=
[
cenPix_X
,
cenPix_Y
]
ipsfMat
=
psfInfo
[
'psfMat'
]
cenX
,
cenY
,
sz
,
e1
,
e2
,
REE80
=
myUtil
.
psfSizeCalculator
(
ipsfMat
,
CalcPSFcenter
=
True
,
SigRange
=
True
,
TailorScheme
=
2
,
cenPix
=
cenPix
)
psf_wvREE80
[
iwave
-
1
,
ipsf
-
1
]
=
REE80
psf4iwave
.
append
(
ipsfMat
)
tt
=
myUtil
.
psfStack
(
psf4iwave
[
0
],
psf4iwave
[
1
],
psf4iwave
[
2
],
psf4iwave
[
3
])
cenX
,
cenY
,
sz
,
e1
,
e2
,
REE80
=
myUtil
.
psfSizeCalculator
(
tt
,
CalcPSFcenter
=
True
,
SigRange
=
True
,
TailorScheme
=
2
)
psf_ttREE80
[
ipsf
-
1
]
=
REE80
if
iccd
==
1
and
iwave
==
1
:
print
(
'iccd-{:}:'
.
format
(
iccd
),
flush
=
True
)
print
(
'psfSet has been loaded.'
,
flush
=
True
)
#print('Usage: psfSet[i][keys]', flush=True)
#print('psfSet.keys:', psfSet[0].keys(), flush=True)
else
:
print
(
'iccd-{:}, iwave-{:}'
.
format
(
iccd
,
iwave
),
end
=
'
\r
'
,
flush
=
True
)
comm
.
barrier
()
psf_ttREE80
=
comm
.
allreduce
(
psf_ttREE80
,
op
=
MPI
.
SUM
)
psf_wvREE80
[
0
,
:]
=
comm
.
allreduce
(
psf_wvREE80
[
0
,
:],
op
=
MPI
.
SUM
)
psf_wvREE80
[
1
,
:]
=
comm
.
allreduce
(
psf_wvREE80
[
1
,
:],
op
=
MPI
.
SUM
)
psf_wvREE80
[
2
,
:]
=
comm
.
allreduce
(
psf_wvREE80
[
2
,
:],
op
=
MPI
.
SUM
)
psf_wvREE80
[
3
,
:]
=
comm
.
allreduce
(
psf_wvREE80
[
3
,
:],
op
=
MPI
.
SUM
)
ttREE80
[
iccd
-
1
]
=
np
.
mean
(
psf_ttREE80
)
wvREE80
[
0
,
iccd
-
1
]
=
np
.
mean
(
psf_wvREE80
[
0
,
:])
wvREE80
[
1
,
iccd
-
1
]
=
np
.
mean
(
psf_wvREE80
[
1
,
:])
wvREE80
[
2
,
iccd
-
1
]
=
np
.
mean
(
psf_wvREE80
[
2
,
:])
wvREE80
[
3
,
iccd
-
1
]
=
np
.
mean
(
psf_wvREE80
[
3
,
:])
##############################
comm
.
barrier
()
#ttREE80 = comm.allreduce(ttREE80, op=MPI.SUM)
#wvREE80 = comm.allreduce(wvREE80, op=MPI.SUM)
#plot-test
if
ThisTask
==
0
:
REE80W1
=
wvREE80
[
0
,
:]
REE80W2
=
wvREE80
[
1
,
:]
REE80W3
=
wvREE80
[
2
,
:]
REE80W4
=
wvREE80
[
3
,
:]
np
.
savetxt
(
'REE50_w1.txt'
,
REE80W1
)
np
.
savetxt
(
'REE50_w2.txt'
,
REE80W2
)
np
.
savetxt
(
'REE50_w3.txt'
,
REE80W3
)
np
.
savetxt
(
'REE50_w4.txt'
,
REE80W4
)
np
.
savetxt
(
'REE50_tt.txt'
,
ttREE80
)
ccdFilterLayout
=
[
'GV'
,
'GV'
,
'GU'
,
'GU'
,
'GI'
,
'y'
,
'i'
,
'g'
,
'r'
,
'GI'
,
'z'
,
'NUV'
,
'NUV'
,
'u'
,
'y'
,
'y'
,
'u'
,
'NUV'
,
'NUV'
,
'z'
,
'GI'
,
'r'
,
'g'
,
'i'
,
'y'
,
'GI'
,
'GU'
,
'GU'
,
'GV'
,
'GV'
]
fig
=
plt
.
figure
(
figsize
=
(
18
,
10
))
for
iccd
in
range
(
0
,
30
):
plt
.
arrow
(
iccd
+
1
,
REE80W1
[
iccd
],
0
,
REE80W4
[
iccd
]
-
REE80W1
[
iccd
],
width
=
0.05
,
head_length
=
0.002
,
ec
=
'None'
,
color
=
'k'
)
plt
.
plot
([
iccd
+
1
],
[
REE80W1
[
iccd
]],
'o'
,
c
=
'k'
)
plt
.
plot
([
iccd
+
1.1
],
[
REE80W2
[
iccd
]],
'o'
,
c
=
'b'
)
plt
.
plot
([
iccd
+
1.2
],
[
REE80W3
[
iccd
]],
'o'
,
c
=
'g'
)
plt
.
plot
([
iccd
+
1.3
],
[
REE80W4
[
iccd
]],
'o'
,
c
=
'r'
)
plt
.
plot
([
iccd
+
1
,
iccd
+
1.1
,
iccd
+
1.2
,
iccd
+
1.3
],
[
REE80W1
[
iccd
],
REE80W2
[
iccd
],
REE80W3
[
iccd
],
REE80W4
[
iccd
]],
'--'
,
c
=
'k'
)
if
REE80W1
[
iccd
]
<
REE80W4
[
iccd
]:
plt
.
text
(
iccd
+
1
-
0.2
,
REE80W1
[
iccd
]
-
0.005
,
ccdFilterLayout
[
iccd
],
fontsize
=
15
)
if
REE80W1
[
iccd
]
>
REE80W4
[
iccd
]:
plt
.
text
(
iccd
+
1
-
0.2
,
REE80W1
[
iccd
]
+
0.003
,
ccdFilterLayout
[
iccd
],
fontsize
=
15
)
plt
.
fill_betweenx
([
0.0
,
0.080
],
[
0.5
,
0.5
],
[
5.5
,
5.5
],
color
=
'gray'
,
alpha
=
0.5
)
plt
.
fill_betweenx
([
0.0
,
0.080
],
[
25.5
,
25.5
],
[
30.5
,
30.5
],
color
=
'gray'
,
alpha
=
0.5
)
plt
.
fill_betweenx
([
0.0
,
0.080
],
[
9.5
,
9.5
],
[
10.5
,
10.5
],
color
=
'gray'
,
alpha
=
0.5
)
plt
.
fill_betweenx
([
0.0
,
0.080
],
[
20.5
,
20.5
],
[
21.5
,
21.5
],
color
=
'gray'
,
alpha
=
0.5
)
plt
.
plot
([
5.5
,
5.5
],
[
0.0
,
0.5
],
':'
)
plt
.
plot
([
10.5
,
10.5
],
[
0.0
,
0.5
],
'k:'
)
plt
.
plot
([
15.5
,
15.5
],
[
0.0
,
0.5
],
'k:'
)
plt
.
plot
([
20.5
,
20.5
],
[
0.0
,
0.5
],
'k:'
)
plt
.
plot
([
25.5
,
25.5
],
[
0.0
,
0.5
],
'k:'
)
plt
.
ylim
(
0.0
,
0.080
)
plt
.
xlim
(
0.5
,
30.5
)
#plt.plot(np.linspace(1, 30, 30), REE80W1)
#plt.plot(np.linspace(1, 30, 30), REE80W2)
#plt.plot(np.linspace(1, 30, 30), REE80W3)
#plt.plot(np.linspace(1, 30, 30), REE80W4)
plt
.
xticks
([])
plt
.
yticks
(
fontsize
=
15
)
plt
.
text
(
1.5
,
-
0.004
,
'CCD1 - CCD5'
,
fontsize
=
15
)
plt
.
text
(
6.5
,
-
0.004
,
'CCD6 - CCD10'
,
fontsize
=
15
)
plt
.
text
(
11.5
,
-
0.004
,
'CCD11 - CCD15'
,
fontsize
=
15
)
plt
.
text
(
16.5
,
-
0.004
,
'CCD16 - CCD20'
,
fontsize
=
15
)
plt
.
text
(
21.5
,
-
0.004
,
'CCD21 - CCD25'
,
fontsize
=
15
)
plt
.
text
(
26.5
,
-
0.004
,
'CCD26 - CCD30'
,
fontsize
=
15
)
plt
.
plot
([
27
],
[
0.183
],
'ko'
)
plt
.
text
(
27.5
,
0.182
,
'wave-1'
,
fontsize
=
15
)
plt
.
plot
([
27
],
[
0.180
],
'ro'
)
plt
.
text
(
27.5
,
0.179
,
'wave-2'
,
fontsize
=
15
)
plt
.
plot
([
27
],
[
0.177
],
'go'
)
plt
.
text
(
27.5
,
0.176
,
'wave-3'
,
fontsize
=
15
)
plt
.
plot
([
27
],
[
0.174
],
'bo'
)
plt
.
text
(
27.5
,
0.173
,
'wave-4'
,
fontsize
=
15
)
#overplot stackedPSF
xccd
=
np
.
linspace
(
1
,
30
,
30
)
plt
.
plot
(
xccd
,
ttREE80
,
'm*'
,
ms
=
20
,
markerfacecolor
=
'None'
,
markeredgewidth
=
2
)
plt
.
plot
([
27
],
[
0.168
],
'm*'
,
ms
=
20
,
markerfacecolor
=
'None'
,
markeredgewidth
=
2
)
plt
.
text
(
27.5
,
0.1665
,
'stacked'
,
fontsize
=
20
)
plt
.
savefig
(
'figs/psfStackedREE50.pdf'
)
##############################
##############################
##############################
if
__name__
==
'__main__'
:
comm
=
MPI
.
COMM_WORLD
ThisTask
=
comm
.
Get_rank
()
NTasks
=
comm
.
Get_size
()
psfPath
=
'/data/simudata/CSSOSDataProductsSims/data/csstPSFdata/CSSOS_psf_20210108/CSST_psf_ciomp_2p5um_cycle3'
test_psfREE80
(
psfPath
,
ThisTask
,
NTasks
)
ObservationSim/PSF/PSFInterp/test/PSFMatsREE80.py
0 → 100644
View file @
29ac5666
import
sys
from
itertools
import
islice
import
mpi4py.MPI
as
MPI
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
matplotlib
as
mpl
mpl
.
use
(
'Agg'
)
import
scipy.io
#import xlrd
from
scipy
import
ndimage
sys
.
path
.
append
(
"/public/home/weichengliang/lnData/CSST_new_framwork/csstPSF_20210108"
)
import
PSFConfig
as
myConfig
import
PSFUtil
as
myUtil
NPSF
=
900
##############################
##############################
##############################
def
test_psfREE80
(
psfPath
,
ThisTask
,
NTasks
):
nccd
=
30
npsf
=
NPSF
npsfPerTasks
=
int
(
npsf
/
NTasks
)
iStart
=
0
+
npsfPerTasks
*
ThisTask
iEnd
=
npsfPerTasks
+
npsfPerTasks
*
ThisTask
if
ThisTask
==
NTasks
:
iEnd
=
npsf
CENPIXUSED
=
True
wvREE80
=
np
.
zeros
([
4
,
nccd
])
#psf in different waves-4
ttREE80
=
np
.
zeros
(
nccd
)
#stacked psf
for
iccd
in
range
(
1
,
nccd
+
1
):
psf_wvREE80
=
np
.
zeros
([
4
,
npsf
])
psf_ttREE80
=
np
.
zeros
(
npsf
)
#for ipsf in range(1, npsf+1):
for
ipsf
in
range
(
iStart
+
1
,
iEnd
+
1
):
psf4iwave
=
[]
for
iwave
in
range
(
1
,
5
):
if
ThisTask
==
0
:
print
(
'iccd-ipsf-iwave: {:} {:} {:}'
.
format
(
iccd
,
ipsf
,
iwave
),
end
=
'
\r
'
)
psfInfo
=
myConfig
.
LoadPSF
(
iccd
,
iwave
,
ipsf
,
psfPath
,
InputMaxPixelPos
=
True
,
PSFCentroidWgt
=
False
)
cenPix
=
None
if
CENPIXUSED
:
psfInfoX
=
myConfig
.
LoadPSF
(
iccd
,
iwave
,
ipsf
,
psfPath
,
InputMaxPixelPos
=
True
,
PSFCentroidWgt
=
True
)
deltX
=
psfInfoX
[
'centroid_x'
]
#in mm
deltY
=
psfInfoX
[
'centroid_y'
]
#in mm
pixsize
=
2.5
*
1e-3
#mm, will use binningPSF
cenPix_X
=
512
/
2
+
deltX
/
pixsize
cenPix_Y
=
512
/
2
+
deltY
/
pixsize
cenPix
=
[
cenPix_X
,
cenPix_Y
]
ipsfMat
=
psfInfo
[
'psfMat'
]
cenX
,
cenY
,
sz
,
e1
,
e2
,
REE80
=
myUtil
.
psfSizeCalculator
(
ipsfMat
,
CalcPSFcenter
=
True
,
SigRange
=
True
,
TailorScheme
=
2
,
cenPix
=
cenPix
)
psf_wvREE80
[
iwave
-
1
,
ipsf
-
1
]
=
REE80
psf4iwave
.
append
(
ipsfMat
)
tt
=
myUtil
.
psfStack
(
psf4iwave
[
0
],
psf4iwave
[
1
],
psf4iwave
[
2
],
psf4iwave
[
3
])
cenX
,
cenY
,
sz
,
e1
,
e2
,
REE80
=
myUtil
.
psfSizeCalculator
(
tt
,
CalcPSFcenter
=
True
,
SigRange
=
True
,
TailorScheme
=
2
)
psf_ttREE80
[
ipsf
-
1
]
=
REE80
if
iccd
==
1
and
iwave
==
1
:
print
(
'iccd-{:}:'
.
format
(
iccd
),
flush
=
True
)
print
(
'psfSet has been loaded.'
,
flush
=
True
)
#print('Usage: psfSet[i][keys]', flush=True)
#print('psfSet.keys:', psfSet[0].keys(), flush=True)
else
:
print
(
'iccd-{:}, iwave-{:}'
.
format
(
iccd
,
iwave
),
end
=
'
\r
'
,
flush
=
True
)
comm
.
barrier
()
psf_ttREE80
=
comm
.
allreduce
(
psf_ttREE80
,
op
=
MPI
.
SUM
)
psf_wvREE80
[
0
,
:]
=
comm
.
allreduce
(
psf_wvREE80
[
0
,
:],
op
=
MPI
.
SUM
)
psf_wvREE80
[
1
,
:]
=
comm
.
allreduce
(
psf_wvREE80
[
1
,
:],
op
=
MPI
.
SUM
)
psf_wvREE80
[
2
,
:]
=
comm
.
allreduce
(
psf_wvREE80
[
2
,
:],
op
=
MPI
.
SUM
)
psf_wvREE80
[
3
,
:]
=
comm
.
allreduce
(
psf_wvREE80
[
3
,
:],
op
=
MPI
.
SUM
)
ttREE80
[
iccd
-
1
]
=
np
.
mean
(
psf_ttREE80
)
wvREE80
[
0
,
iccd
-
1
]
=
np
.
mean
(
psf_wvREE80
[
0
,
:])
wvREE80
[
1
,
iccd
-
1
]
=
np
.
mean
(
psf_wvREE80
[
1
,
:])
wvREE80
[
2
,
iccd
-
1
]
=
np
.
mean
(
psf_wvREE80
[
2
,
:])
wvREE80
[
3
,
iccd
-
1
]
=
np
.
mean
(
psf_wvREE80
[
3
,
:])
##############################
comm
.
barrier
()
#ttREE80 = comm.allreduce(ttREE80, op=MPI.SUM)
#wvREE80 = comm.allreduce(wvREE80, op=MPI.SUM)
#plot-test
if
ThisTask
==
0
:
REE80W1
=
wvREE80
[
0
,
:]
REE80W2
=
wvREE80
[
1
,
:]
REE80W3
=
wvREE80
[
2
,
:]
REE80W4
=
wvREE80
[
3
,
:]
np
.
savetxt
(
'REE80_w1.txt'
,
REE80W1
)
np
.
savetxt
(
'REE80_w2.txt'
,
REE80W2
)
np
.
savetxt
(
'REE80_w3.txt'
,
REE80W3
)
np
.
savetxt
(
'REE80_w4.txt'
,
REE80W4
)
np
.
savetxt
(
'REE80_tt.txt'
,
ttREE80
)
ccdFilterLayout
=
[
'GV'
,
'GV'
,
'GU'
,
'GU'
,
'GI'
,
'y'
,
'i'
,
'g'
,
'r'
,
'GI'
,
'z'
,
'NUV'
,
'NUV'
,
'u'
,
'y'
,
'y'
,
'u'
,
'NUV'
,
'NUV'
,
'z'
,
'GI'
,
'r'
,
'g'
,
'i'
,
'y'
,
'GI'
,
'GU'
,
'GU'
,
'GV'
,
'GV'
]
fig
=
plt
.
figure
(
figsize
=
(
18
,
10
))
for
iccd
in
range
(
0
,
30
):
plt
.
arrow
(
iccd
+
1
,
REE80W1
[
iccd
],
0
,
REE80W4
[
iccd
]
-
REE80W1
[
iccd
],
width
=
0.05
,
head_length
=
0.002
,
ec
=
'None'
,
color
=
'k'
)
plt
.
plot
([
iccd
+
1
],
[
REE80W1
[
iccd
]],
'o'
,
c
=
'k'
)
plt
.
plot
([
iccd
+
1.1
],
[
REE80W2
[
iccd
]],
'o'
,
c
=
'b'
)
plt
.
plot
([
iccd
+
1.2
],
[
REE80W3
[
iccd
]],
'o'
,
c
=
'g'
)
plt
.
plot
([
iccd
+
1.3
],
[
REE80W4
[
iccd
]],
'o'
,
c
=
'r'
)
plt
.
plot
([
iccd
+
1
,
iccd
+
1.1
,
iccd
+
1.2
,
iccd
+
1.3
],
[
REE80W1
[
iccd
],
REE80W2
[
iccd
],
REE80W3
[
iccd
],
REE80W4
[
iccd
]],
'--'
,
c
=
'k'
)
if
REE80W1
[
iccd
]
<
REE80W4
[
iccd
]:
plt
.
text
(
iccd
+
1
-
0.2
,
REE80W1
[
iccd
]
-
0.005
,
ccdFilterLayout
[
iccd
],
fontsize
=
15
)
if
REE80W1
[
iccd
]
>
REE80W4
[
iccd
]:
plt
.
text
(
iccd
+
1
-
0.2
,
REE80W1
[
iccd
]
+
0.003
,
ccdFilterLayout
[
iccd
],
fontsize
=
15
)
plt
.
fill_betweenx
([
0.078
,
0.145
],
[
0.5
,
0.5
],
[
5.5
,
5.5
],
color
=
'gray'
,
alpha
=
0.5
)
plt
.
fill_betweenx
([
0.078
,
0.145
],
[
25.5
,
25.5
],
[
30.5
,
30.5
],
color
=
'gray'
,
alpha
=
0.5
)
plt
.
fill_betweenx
([
0.078
,
0.145
],
[
9.5
,
9.5
],
[
10.5
,
10.5
],
color
=
'gray'
,
alpha
=
0.5
)
plt
.
fill_betweenx
([
0.078
,
0.145
],
[
20.5
,
20.5
],
[
21.5
,
21.5
],
color
=
'gray'
,
alpha
=
0.5
)
plt
.
plot
([
5.5
,
5.5
],
[
0.078
,
0.5
],
':'
)
plt
.
plot
([
10.5
,
10.5
],
[
0.078
,
0.5
],
'k:'
)
plt
.
plot
([
15.5
,
15.5
],
[
0.078
,
0.5
],
'k:'
)
plt
.
plot
([
20.5
,
20.5
],
[
0.078
,
0.5
],
'k:'
)
plt
.
plot
([
25.5
,
25.5
],
[
0.078
,
0.5
],
'k:'
)
plt
.
ylim
(
0.078
,
0.145
)
plt
.
xlim
(
0.5
,
30.5
)
#plt.plot(np.linspace(1, 30, 30), REE80W1)
#plt.plot(np.linspace(1, 30, 30), REE80W2)
#plt.plot(np.linspace(1, 30, 30), REE80W3)
#plt.plot(np.linspace(1, 30, 30), REE80W4)
plt
.
xticks
([])
plt
.
yticks
(
fontsize
=
15
)
plt
.
text
(
1.5
,
0.074
,
'CCD1 - CCD5'
,
fontsize
=
15
)
plt
.
text
(
6.5
,
0.074
,
'CCD6 - CCD10'
,
fontsize
=
15
)
plt
.
text
(
11.5
,
0.074
,
'CCD11 - CCD15'
,
fontsize
=
15
)
plt
.
text
(
16.5
,
0.074
,
'CCD16 - CCD20'
,
fontsize
=
15
)
plt
.
text
(
21.5
,
0.074
,
'CCD21 - CCD25'
,
fontsize
=
15
)
plt
.
text
(
26.5
,
0.074
,
'CCD26 - CCD30'
,
fontsize
=
15
)
plt
.
plot
([
27
],
[
0.183
],
'ko'
)
plt
.
text
(
27.5
,
0.182
,
'wave-1'
,
fontsize
=
15
)
plt
.
plot
([
27
],
[
0.180
],
'ro'
)
plt
.
text
(
27.5
,
0.179
,
'wave-2'
,
fontsize
=
15
)
plt
.
plot
([
27
],
[
0.177
],
'go'
)
plt
.
text
(
27.5
,
0.176
,
'wave-3'
,
fontsize
=
15
)
plt
.
plot
([
27
],
[
0.174
],
'bo'
)
plt
.
text
(
27.5
,
0.173
,
'wave-4'
,
fontsize
=
15
)
#overplot stackedPSF
xccd
=
np
.
linspace
(
1
,
30
,
30
)
plt
.
plot
(
xccd
,
ttREE80
,
'm*'
,
ms
=
20
,
markerfacecolor
=
'None'
,
markeredgewidth
=
2
)
plt
.
plot
([
27
],
[
0.168
],
'm*'
,
ms
=
20
,
markerfacecolor
=
'None'
,
markeredgewidth
=
2
)
plt
.
text
(
27.5
,
0.1665
,
'stacked'
,
fontsize
=
20
)
plt
.
savefig
(
'figs/psfStackedREE80.pdf'
)
##############################
##############################
##############################
if
__name__
==
'__main__'
:
comm
=
MPI
.
COMM_WORLD
ThisTask
=
comm
.
Get_rank
()
NTasks
=
comm
.
Get_size
()
psfPath
=
'/data/simudata/CSSOSDataProductsSims/data/csstPSFdata/CSSOS_psf_20210108/CSST_psf_ciomp_2p5um_cycle3'
test_psfREE80
(
psfPath
,
ThisTask
,
NTasks
)
ObservationSim/PSF/PSFInterp/test/REE50_tt.txt
0 → 100644
View file @
29ac5666
4.192623714192045964e-02
3.963687271293666464e-02
3.717499316773480861e-02
3.547479454427957674e-02
4.778017809407578836e-02
5.589890449411339529e-02
4.521611930595503814e-02
3.177118275728490343e-02
3.778880075862010163e-02
4.599476550188329183e-02
5.217386429508526907e-02
2.741515900111860665e-02
2.751147872664862215e-02
2.593041263934638824e-02
5.550626295722193432e-02
5.590932749625709269e-02
2.809689362429910325e-02
3.039854779218633882e-02
2.730709160574608385e-02
5.228841161148415490e-02
4.721563391801383847e-02
3.853965697603093515e-02
3.288221512817673942e-02
4.526867814362049020e-02
5.549804478055900964e-02
4.864927207016282729e-02
3.085322873873843144e-02
2.899995189367069251e-02
3.424865529768996580e-02
3.627621793291634783e-02
ObservationSim/PSF/PSFInterp/test/REE50_w1.txt
0 → 100644
View file @
29ac5666
4.097674760967492946e-02
3.779118013257781739e-02
3.854422118514776174e-02
3.604302387477623104e-02
4.097642137358586262e-02
5.422652423381805337e-02
4.271208368655707993e-02
2.862325804928938719e-02
3.484749293989605062e-02
3.973479835109577918e-02
4.960958740777439424e-02
3.018300496041774819e-02
2.993626710027456200e-02
2.408132943635185597e-02
5.361761418067746698e-02
5.386454740332232566e-02
2.540567224224408310e-02
3.506318612438109189e-02
2.746613206341862526e-02
4.962374180969264525e-02
4.058798617786830987e-02
3.485660712545116807e-02
2.843817778345611447e-02
4.183941396160258119e-02
5.364700755725304582e-02
4.234843995836046204e-02
2.858904785580105093e-02
2.490848023651374629e-02
2.915432476335101664e-02
3.297398504283693271e-02
ObservationSim/PSF/PSFInterp/test/REE50_w2.txt
0 → 100644
View file @
29ac5666
4.107249135358465725e-02
3.805210295857654884e-02
3.634435170433587825e-02
3.354171364878615058e-02
4.468210332095622767e-02
5.541175949904653814e-02
4.455799478623602428e-02
3.044745398064454406e-02
3.644618252085314591e-02
4.342479083273145801e-02
5.033345324711667457e-02
2.592496615524093190e-02
2.602256835955712652e-02
2.419794542507992807e-02
5.424795392072863376e-02
5.454469751566648483e-02
2.579547411865658335e-02
2.818417717392246100e-02
2.520566607515017238e-02
5.040185143550236779e-02
4.456572487950324901e-02
3.643000928892029672e-02
3.032562015371190189e-02
4.340189202792114898e-02
5.436048106186919943e-02
4.582877747714519251e-02
2.675305432329575309e-02
2.434911420775784374e-02
3.196721636172798059e-02
3.480462196800444136e-02
ObservationSim/PSF/PSFInterp/test/REE50_w3.txt
0 → 100644
View file @
29ac5666
4.197429738938808497e-02
3.948407693869537827e-02
3.499825730091995352e-02
3.239083757003148600e-02
4.886476772940821084e-02
5.656497548437780520e-02
4.575395000891552960e-02
3.229455917659732750e-02
3.790552155839072013e-02
4.727557896325985248e-02
5.229303643521335254e-02
2.517534267157316152e-02
2.533119356673624659e-02
2.559196881535980364e-02
5.552474377469884120e-02
5.606734792805380396e-02
2.605791410017344739e-02
2.653578668625818440e-02
2.488602056892381606e-02
5.237050928589370713e-02
4.864922908859120598e-02
3.793197987808121646e-02
3.199448413319058021e-02
4.567710663295454498e-02
5.582077370749579520e-02
4.991082506461275853e-02
2.695475944835278720e-02
2.495457686276899428e-02
3.456866744284828319e-02
3.673887742269370260e-02
ObservationSim/PSF/PSFInterp/test/REE50_w4.txt
0 → 100644
View file @
29ac5666
4.374798665444055989e-02
4.172032311144802108e-02
3.449644779165585845e-02
3.227750844632586158e-02
5.347426552325486998e-02
5.790241428133514195e-02
4.830917320731613340e-02
3.390226654708385773e-02
4.048860900104046118e-02
5.229343653966982836e-02
5.546085886657237812e-02
2.504612732885612425e-02
2.524040076881647193e-02
2.594595272300971936e-02
5.741710940168963384e-02
5.757535632285806781e-02
2.622993558438287826e-02
2.619012944814231789e-02
2.490559814497828386e-02
5.549698290725549321e-02
5.351221157444847887e-02
4.031978600141074981e-02
3.390058320636550604e-02
4.747320735620128018e-02
5.750102566348181538e-02
5.429367550131347642e-02
2.792105174933870795e-02
2.611095883366134490e-02
3.699269230580991968e-02
3.936049576848745651e-02
Prev
1
…
3
4
5
6
7
8
9
10
11
…
42
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment