-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from patricialarsen/shear_test
Shear test
- Loading branch information
Showing
6 changed files
with
185 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,26 @@ | ||
subclass_name: srv_ngals.CheckNgals | ||
description: 'Check flags' | ||
included_by_default: true | ||
|
||
ra: 'ra' | ||
dec: 'dec' | ||
nside: 64 | ||
|
||
flags_to_check: | ||
- quantities: 'psFlux_flag_u' | ||
kind: 'bool' | ||
flag_val: True | ||
flag_val: False | ||
|
||
- quantities: 'good' | ||
kind: 'bool' | ||
flag_val: True | ||
flag_val: False | ||
|
||
- quantities: 'I_flag' | ||
kind: 'bool' | ||
flag_val: True | ||
flag_val: False | ||
|
||
- quantities: 'cModelFlux_flag_r' | ||
kind: 'bool' | ||
flag_val: True | ||
flag_val: False | ||
|
||
catalog_filters: | ||
|
||
- filters: ['mag_r < 28', 'mag_i < 28'] | ||
- filters: ['extendedness==1'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
""" | ||
MPI-related utility functions for descqa | ||
""" | ||
from __future__ import unicode_literals, division, print_function, absolute_import | ||
import numpy as np | ||
from mpi4py import MPI | ||
|
||
comm = MPI.COMM_WORLD | ||
size = comm.Get_size() | ||
rank = comm.Get_rank() | ||
|
||
|
||
__all__ = [ | ||
'send_to_master', | ||
'get_ra_dec', | ||
] | ||
|
||
|
||
def send_to_master(value, kind): | ||
""" | ||
Parameters | ||
---------- | ||
value : ndarray | ||
rank-local array of values to communicate | ||
kind : str | ||
type of variable. Currently implemented options are double, bool | ||
Returns | ||
------- | ||
recvbuf : ndarray | ||
array of all rank values for rank 0 | ||
None value otherwise | ||
""" | ||
count = len(value) | ||
tot_num = comm.reduce(count) | ||
counts = comm.allgather(count) | ||
|
||
if rank==0: | ||
if kind=='double': | ||
recvbuf = np.zeros(tot_num) | ||
elif kind=='bool': | ||
recvbuf = np.zeros(tot_num)!=0.0 | ||
else: | ||
raise NotImplementedError | ||
else: | ||
recvbuf = None | ||
|
||
displs = np.array([sum(counts[:p]) for p in range(size)]) | ||
if kind=='double': | ||
comm.Gatherv([value,MPI.DOUBLE], [recvbuf,counts,displs,MPI.DOUBLE],root=0) | ||
elif kind=='float': | ||
comm.Gatherv([value,MPI.FLOAT], [recvbuf,counts,displs,MPI.FLOAT],root=0) | ||
elif kind=='int': | ||
comm.Gatherv([value,MPI.INT], [recvbuf,counts,displs,MPI.INT],root=0) | ||
elif kind=='bool': | ||
comm.Gatherv([value,MPI.BOOL], [recvbuf,counts,displs,MPI.BOOL],root=0) | ||
elif kind=='int64': | ||
comm.Gatherv([value,MPI.INT64_T], [recvbuf, counts, displs, MPI.INT64_T],root=0) | ||
else: | ||
raise NotImplementedError | ||
|
||
return recvbuf | ||
|
||
|
||
def get_ra_dec(ra,dec,catalog_data): | ||
""" | ||
Parameters | ||
---------- | ||
ra : str | ||
variable name representing right ascension | ||
dec: str | ||
variable name representing declination | ||
catalog_data : GCRCatalog object | ||
GCRCatalog object holding catalog data | ||
Returns | ||
------- | ||
recvbuf_ra : ndarray | ||
rank 0 outputs array of all ra values | ||
other ranks output a None value | ||
recvbuf_dec : ndarray | ||
rank 0 outputs array of all dec values | ||
other ranks output a None value | ||
""" | ||
data_rank={} | ||
recvbuf={} | ||
for quantity in [ra,dec]: | ||
data_rank[quantity] = catalog_data[quantity] | ||
count = len(data_rank[quantity]) | ||
tot_num = comm.reduce(count) | ||
counts = comm.allgather(count) | ||
if rank==0: | ||
recvbuf[quantity] = np.zeros(tot_num) | ||
else: | ||
recvbuf[quantity] = None | ||
displs = np.array([sum(counts[:p]) for p in range(size)]) | ||
comm.Gatherv([data_rank[quantity],MPI.DOUBLE], [recvbuf[quantity], counts, displs, MPI.DOUBLE],root=0) | ||
recvbuf_ra = recvbuf[ra] | ||
recvbuf_dec = recvbuf[dec] | ||
|
||
return recvbuf_ra, recvbuf_dec | ||
|
Oops, something went wrong.