当前位置: 首页>>代码示例>>Python>>正文


Python Query.query_box方法代码示例

本文整理汇总了Python中query.Query.query_box方法的典型用法代码示例。如果您正苦于以下问题:Python Query.query_box方法的具体用法?Python Query.query_box怎么用?Python Query.query_box使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在query.Query的用法示例。


在下文中一共展示了Query.query_box方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ShowSkyCoverage

# 需要导入模块: from query import Query [as 别名]
# 或者: from query.Query import query_box [as 别名]
class ShowSkyCoverage(object): 
    """Moving the FoV-footprint coverage by choosing a starting pointing."""
    
    SHIFT_CORRECTION = 0.00001  # A shift correction of 0.00001 is added
                                 # --> to escape math error during the FoV sequence

    def __init__(self, infile_coords='GWsky_coords'):
        """Creating a class in which the instance attributes are based on the dictionary
       "GWsky_coords" by default. GWsky_coords is created and pickled by the "user_values"
       module and will be deleted when the "ShowSkyCoverageGUI" will be closed.
       It contains the keys: "ra", "dec". ra and dec represents the central location of a FoV. 
        
        Starting sky coordinates:
             self.input_ra: right ascension [deg]
             self.input_dec: declination [deg]
         """
       
        self.infile_coords = infile_coords
        self.entries_GWsky_new =[] # new entries during the FoV sequence
        
        self.user = UserValues() # compositions
        self.lvc = LVCskymap()
        self.query = Query()
        self.airmass = Airmass()
        self.moon = Moon()
        
        with open(infile_coords, 'rb') as data:  
            coords_GWsky = pickle.load(data)
            
        for k, v in coords_GWsky.items():          
            setattr(self, k, v)
            
            
    def ra0ra1(self, A, dec0, dec1):
        """From the angular distance:
           cos(A) = sin(Dec1)sin(Dec2)+cos(Dec1)cos(Dec2)cos(ra1-ra2) --> 
           cos(ra1-ra2) = [cos(A)-sin(dec0)sin(dec1)]/[cos(dec0)cos(dec1)]."""

        dec0, dec1, A = radians(dec0),  radians(dec1), radians(A)
        cos_ra0_ra1 = ( cos(A)-sin(dec0)*sin(dec1) )/( cos(dec0)*cos(dec1) )
        ra0ra1 = degrees( acos(cos_ra0_ra1) )

        return  round(ra0ra1, 5)         
    
    def __updating_center_coords(self, ra, dec):
        """Getting/Updating FoV-center (ra, dec) in the dict named by default "GWsky_coords".
.          For each tile across the sky the file is updated."""""

        with open('GWsky_coords', 'rb') as data:
            coords_GWsky = pickle.load(data)
            
        coords_GWsky['input_ra'], coords_GWsky ['input_dec'] = ra, dec

        with open('GWsky_coords', 'wb') as data:
            pickle.dump(coords_GWsky, data)
   
    def __are_all_same(self, items):
        """Check if all elements of a list are the same."""
        
        return all(x == items[0] for x in items)

    def __fov_stats(self, ra, dec, table, integrated_prob, distance_grid, ansatz_distribution, moon_illumination):    
        """Managing the descriptive statistic window. If the airmass is outside the default range [airmass_min, airmass_max]
            the window is not opened otherwise the window is shown."""
        
        airmass_values, datestrings = self.airmass.airmass_step(ra, dec) 
        same = self.__are_all_same(airmass_values) 
                                                 
        if same == True:
            tkMessageBox.showerror('Warning',"airmass outside the range of {1 - 5.8}")
            aladin.remove_FoV(ra, dec) 
            aladin.remove("C_" + str( ra ) + "/" + str( dec ))  
        else:
            time_step = [dateutil.parser.parse(s) for s in datestrings]
            self.__updating_center_coords(ra,dec)  
            fov_statistics = FoVstatistics()                 
            fov_statistics.plot_stats(time_step, airmass_values,
                                      ra, dec,
                                      table,
                                      integrated_prob,
                                      distance_grid, ansatz_distribution, moon_illumination)
        print airmass_values, datestrings
    
    def update_pointings_file(self, infile, ra, dec, prob_fov):
         """The central location (ra[deg], dec[deg]) and the integrated probability of
             a selected FoV are saved locally in an external file.
             By default the file is named "GWsky_pointings.txt"."""
           
         with open(infile, 'a') as pointing:
             pointing.write(str(ra) + ' ' + str(dec)+ ' '+ str(prob_fov)+'\n')

    def __query_shape(self, ra, dec, fov_shape):
        """Return the catalog query according with the defined-user FoV shape:
                   (1) box and (2) circle. """
        
        if self.user.get_fov_shape() != 2:  # box FoV
                    query_result = self.query.query_box(
                       ra, dec, self.user.get_fov_width(), self.user.get_fov_height(), self.user.get_catalog(),
                       self.user.get_column_1(), self.user.get_column_2(),
                       self.user.get_filter_1(), self.user.get_filter_2())               
#.........这里部分代码省略.........
开发者ID:ggreco77,项目名称:Multi-Order-Coverage-of-probability-skymaps,代码行数:103,代码来源:coverage31M.py


注:本文中的query.Query.query_box方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。