idx int64 0 63k | question stringlengths 53 5.28k | target stringlengths 5 805 |
|---|---|---|
47,700 | def change_user_name ( self , usrname , newusrname , callback = None ) : params = { 'usrName' : usrname , 'newUsrName' : newusrname , } return self . execute_command ( 'changeUserName' , params , callback = callback ) | Change user name . |
47,701 | def change_password ( self , usrname , oldpwd , newpwd , callback = None ) : params = { 'usrName' : usrname , 'oldPwd' : oldpwd , 'newPwd' : newpwd , } return self . execute_command ( 'changePassword' , params , callback = callback ) | Change password . |
47,702 | def set_system_time ( self , time_source , ntp_server , date_format , time_format , time_zone , is_dst , dst , year , mon , day , hour , minute , sec , callback = None ) : if ntp_server not in [ 'time.nist.gov' , 'time.kriss.re.kr' , 'time.windows.com' , 'time.nuri.net' , ] : raise ValueError ( 'Unsupported ntpServer' ... | Set systeim time |
47,703 | def set_dev_name ( self , devname , callback = None ) : params = { 'devName' : devname . encode ( 'gbk' ) } return self . execute_command ( 'setDevName' , params , callback = callback ) | Set camera name |
47,704 | def ptz_goto_preset ( self , name , callback = None ) : params = { 'name' : name } return self . execute_command ( 'ptzGotoPresetPoint' , params , callback = callback ) | Move to preset . |
47,705 | def get_apcor ( expnum , ccd , version = 'p' , prefix = None ) : uri = get_uri ( expnum , ccd , ext = APCOR_EXT , version = version , prefix = prefix ) apcor_file_name = tempfile . NamedTemporaryFile ( ) client . copy ( uri , apcor_file_name . name ) apcor_file_name . seek ( 0 ) return [ float ( x ) for x in apcor_file... | retrieve the aperture correction for this exposure |
47,706 | def populate ( dataset_name , data_web_service_url = DATA_WEB_SERVICE + "CFHT" ) : data_dest = get_uri ( dataset_name , version = 'o' , ext = FITS_EXT ) data_source = "%s/%so.{}" % ( data_web_service_url , dataset_name , FITS_EXT ) mkdir ( os . path . dirname ( data_dest ) ) try : client . link ( data_source , data_des... | Given a dataset_name created the desired dbimages directories and links to the raw data files stored at CADC . |
47,707 | def get_cands_uri ( field , ccd , version = 'p' , ext = 'measure3.cands.astrom' , prefix = None , block = None ) : if prefix is None : prefix = "" if len ( prefix ) > 0 : prefix += "_" if len ( field ) > 0 : field += "_" if ext is None : ext = "" if len ( ext ) > 0 and ext [ 0 ] != "." : ext = ".{}" . format ( ext ) me... | return the nominal URI for a candidate file . |
47,708 | def get_uri ( expnum , ccd = None , version = 'p' , ext = FITS_EXT , subdir = None , prefix = None ) : if subdir is None : subdir = str ( expnum ) if prefix is None : prefix = '' uri = os . path . join ( DBIMAGES , subdir ) if ext is None : ext = '' elif len ( ext ) > 0 and ext [ 0 ] != '.' : ext = '.' + ext if version... | Build the uri for an OSSOS image stored in the dbimages containerNode . |
47,709 | def get_tag ( expnum , key ) : uri = tag_uri ( key ) force = uri not in get_tags ( expnum ) value = get_tags ( expnum , force = force ) . get ( uri , None ) return value | given a key return the vospace tag value . |
47,710 | def get_process_tag ( program , ccd , version = 'p' ) : return "%s_%s%s" % ( program , str ( version ) , str ( ccd ) . zfill ( 2 ) ) | make a process tag have a suffix indicating which ccd its for . |
47,711 | def get_status ( task , prefix , expnum , version , ccd , return_message = False ) : key = get_process_tag ( prefix + task , ccd , version ) status = get_tag ( expnum , key ) logger . debug ( '%s: %s' % ( key , status ) ) if return_message : return status else : return status == SUCCESS | Report back status of the given program by looking up the associated VOSpace annotation . |
47,712 | def set_status ( task , prefix , expnum , version , ccd , status ) : return set_tag ( expnum , get_process_tag ( prefix + task , ccd , version ) , status ) | set the processing status of the given program . |
47,713 | def frame2expnum ( frameid ) : result = { } parts = re . search ( '(?P<expnum>\d{7})(?P<type>\S)(?P<ccd>\d\d)' , frameid ) assert parts is not None result [ 'expnum' ] = parts . group ( 'expnum' ) result [ 'ccd' ] = parts . group ( 'ccd' ) result [ 'version' ] = parts . group ( 'type' ) return result | Given a standard OSSOS frameid return the expnum version and ccdnum as a dictionary . |
47,714 | def reset_datasec ( cutout , datasec , naxis1 , naxis2 ) : if cutout is None or cutout == "[*,*]" : return datasec try : datasec = datasec_to_list ( datasec ) except : return datasec cutout = cutout . replace ( " " , "" ) cutout = cutout . replace ( "[-*," , "{}:1," . format ( naxis1 ) ) cutout = cutout . replace ( ",-... | reset the datasec to account for a possible cutout . |
47,715 | def get_hdu ( uri , cutout = None ) : try : filename = os . path . basename ( uri ) if os . access ( filename , os . F_OK ) and cutout is None : logger . debug ( "File already on disk: {}" . format ( filename ) ) hdu_list = fits . open ( filename , scale_back = True ) hdu_list . verify ( 'silentfix+ignore' ) else : log... | Get a at the given uri from VOSpace possibly doing a cutout . |
47,716 | def get_fwhm_tag ( expnum , ccd , prefix = None , version = 'p' ) : uri = get_uri ( expnum , ccd , version , ext = 'fwhm' , prefix = prefix ) if uri not in fwhm : key = "fwhm_{:1s}{:02d}" . format ( version , int ( ccd ) ) fwhm [ uri ] = get_tag ( expnum , key ) return fwhm [ uri ] | Get the FWHM from the VOSpace annotation . |
47,717 | def _get_zeropoint ( expnum , ccd , prefix = None , version = 'p' ) : if prefix is not None : DeprecationWarning ( "Prefix is no longer used here as the 'fk' and 's' have the same zeropoint." ) key = "zeropoint_{:1s}{:02d}" . format ( version , int ( ccd ) ) return get_tag ( expnum , key ) | Retrieve the zeropoint stored in the tags associated with this image . |
47,718 | def get_zeropoint ( expnum , ccd , prefix = None , version = 'p' ) : uri = get_uri ( expnum , ccd , version , ext = 'zeropoint.used' , prefix = prefix ) try : return zmag [ uri ] except : pass try : zmag [ uri ] = float ( open_vos_or_local ( uri ) . read ( ) ) return zmag [ uri ] except : pass zmag [ uri ] = 0.0 return... | Get the zeropoint for this exposure using the zeropoint . used file created during source planting .. |
47,719 | def mkdir ( dirname ) : dir_list = [ ] while not client . isdir ( dirname ) : dir_list . append ( dirname ) dirname = os . path . dirname ( dirname ) while len ( dir_list ) > 0 : logging . info ( "Creating directory: %s" % ( dir_list [ - 1 ] ) ) try : client . mkdir ( dir_list . pop ( ) ) except IOError as e : if e . e... | make directory tree in vospace . |
47,720 | def vofile ( filename , ** kwargs ) : basename = os . path . basename ( filename ) if os . access ( basename , os . R_OK ) : return open ( basename , 'r' ) kwargs [ 'view' ] = kwargs . get ( 'view' , 'data' ) return client . open ( filename , ** kwargs ) | Open and return a handle on a VOSpace data connection |
47,721 | def open_vos_or_local ( path , mode = "rb" ) : filename = os . path . basename ( path ) if os . access ( filename , os . F_OK ) : return open ( filename , mode ) if path . startswith ( "vos:" ) : primary_mode = mode [ 0 ] if primary_mode == "r" : vofile_mode = os . O_RDONLY elif primary_mode == "w" : vofile_mode = os .... | Opens a file which can either be in VOSpace or the local filesystem . |
47,722 | def copy ( source , dest ) : logger . info ( "copying {} -> {}" . format ( source , dest ) ) return client . copy ( source , dest ) | use the vospace service to get a file . |
47,723 | def vlink ( s_expnum , s_ccd , s_version , s_ext , l_expnum , l_ccd , l_version , l_ext , s_prefix = None , l_prefix = None ) : source_uri = get_uri ( s_expnum , ccd = s_ccd , version = s_version , ext = s_ext , prefix = s_prefix ) link_uri = get_uri ( l_expnum , ccd = l_ccd , version = l_version , ext = l_ext , prefix... | make a link between two version of a file . |
47,724 | def delete ( expnum , ccd , version , ext , prefix = None ) : uri = get_uri ( expnum , ccd = ccd , version = version , ext = ext , prefix = prefix ) remove ( uri ) | delete a file no error on does not exist |
47,725 | def my_glob ( pattern ) : result = [ ] if pattern [ 0 : 4 ] == 'vos:' : dirname = os . path . dirname ( pattern ) flist = listdir ( dirname ) for fname in flist : fname = '/' . join ( [ dirname , fname ] ) if fnmatch . fnmatch ( fname , pattern ) : result . append ( fname ) else : result = glob ( pattern ) return resul... | get a listing matching pattern |
47,726 | def has_property ( node_uri , property_name , ossos_base = True ) : if get_property ( node_uri , property_name , ossos_base ) is None : return False else : return True | Checks if a node in VOSpace has the specified property . |
47,727 | def get_property ( node_uri , property_name , ossos_base = True ) : node = client . get_node ( node_uri , force = True ) property_uri = tag_uri ( property_name ) if ossos_base else property_name if property_uri not in node . props : return None return node . props [ property_uri ] | Retrieves the value associated with a property on a node in VOSpace . |
47,728 | def set_property ( node_uri , property_name , property_value , ossos_base = True ) : node = client . get_node ( node_uri ) property_uri = tag_uri ( property_name ) if ossos_base else property_name if property_uri in node . props : node . props [ property_uri ] = None client . add_props ( node ) node . props [ property_... | Sets the value of a property on a node in VOSpace . If the property already has a value then it is first cleared and then set . |
47,729 | def increment_object_counter ( node_uri , epoch_field , dry_run = False ) : current_count = read_object_counter ( node_uri , epoch_field , dry_run = dry_run ) if current_count is None : new_count = "01" else : new_count = coding . base36encode ( coding . base36decode ( current_count ) + 1 , pad_length = 2 ) set_propert... | Increment the object counter used to create unique object identifiers . |
47,730 | def get_mopheader ( expnum , ccd , version = 'p' , prefix = None ) : prefix = prefix is None and "" or prefix mopheader_uri = dbimages_uri ( expnum = expnum , ccd = ccd , version = version , prefix = prefix , ext = '.mopheader' ) if mopheader_uri in mopheaders : return mopheaders [ mopheader_uri ] filename = os . path ... | Retrieve the mopheader either from cache or from vospace |
47,731 | def _get_sghead ( expnum ) : version = 'p' key = "{}{}" . format ( expnum , version ) if key in sgheaders : return sgheaders [ key ] url = "http://www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca/data/pub/CFHTSG/{}{}.head" . format ( expnum , version ) logging . getLogger ( "requests" ) . setLevel ( logging . ERROR ) logging . deb... | Use the data web service to retrieve the stephen s astrometric header . |
47,732 | def get_header ( uri ) : if uri not in astheaders : astheaders [ uri ] = get_hdu ( uri , cutout = "[1:1,1:1]" ) [ 0 ] . header return astheaders [ uri ] | Pull a FITS header from observation at the given URI |
47,733 | def get_astheader ( expnum , ccd , version = 'p' , prefix = None ) : logger . debug ( "Getting ast header for {}" . format ( expnum ) ) if version == 'p' : try : sg_key = "{}{}" . format ( expnum , version ) if sg_key not in sgheaders : _get_sghead ( expnum ) if sg_key in sgheaders : for header in sgheaders [ sg_key ] ... | Retrieve the header for a given dbimages file . |
47,734 | def tag ( self ) : return "{}{}_{}{:02d}" . format ( self . target . prefix , self , self . target . version , self . target . ccd ) | Get the string representation of the tag used to annotate the status in VOSpace . |
47,735 | def scramble ( expnums , ccd , version = 'p' , dry_run = False ) : mjds = [ ] fobjs = [ ] for expnum in expnums : filename = storage . get_image ( expnum , ccd = ccd , version = version ) fobjs . append ( fits . open ( filename ) ) mjds . append ( fobjs [ - 1 ] [ 0 ] . header [ 'MJD-OBS' ] ) order = [ 0 , 2 , 1 ] for i... | run the plant script on this combination of exposures |
47,736 | def read_cands ( filename ) : import sre lines = file ( filename ) . readlines ( ) exps = [ ] cands = [ ] coo = [ ] for line in lines : if ( line [ 0 : 2 ] == "##" ) : break exps . append ( line [ 2 : ] . strip ( ) ) for line in lines : if ( line [ 0 ] == "#" ) : continue if len ( line . strip ( ) ) == 0 : if len ( coo... | Read in the contents of a cands comb file |
47,737 | def query_for_observations ( mjd , observable , runid_list ) : data = { "QUERY" : ( "SELECT Observation.target_name as TargetName, " "COORD1(CENTROID(Plane.position_bounds)) AS RA," "COORD2(CENTROID(Plane.position_bounds)) AS DEC, " "Plane.time_bounds_lower AS StartDate, " "Plane.time_exposure AS ExposureTime, " "Obser... | Do a QUERY on the TAP service for all observations that are part of runid where taken after mjd and have calibration observable . |
47,738 | def crpix ( self ) : try : return self . wcs . crpix1 , self . wcs . crpix2 except Exception as ex : logging . debug ( "Couldn't get CRPIX from WCS: {}" . format ( ex ) ) logging . debug ( "Switching to use DATASEC for CRPIX value computation." ) try : ( x1 , x2 ) , ( y1 , y2 ) = util . get_pixel_bounds_from_datasec_ke... | The location of the reference coordinate in the pixel frame . |
47,739 | def mjd_obsc ( self ) : try : utc_end = self [ 'UTCEND' ] exposure_time = float ( self [ 'EXPTIME' ] ) date_obs = self [ 'DATE-OBS' ] except KeyError as ke : raise KeyError ( "Header missing keyword: {}, required for MJD-OBSC computation" . format ( ke . args [ 0 ] ) ) utc_end = Time ( date_obs + "T" + utc_end ) utc_ce... | Given a CFHT Megaprime image header compute the center of exposure . |
47,740 | def crval ( self ) : try : return self . wcs . crval1 , self . wcs . crval2 except Exception as ex : logging . debug ( "Couldn't get CRVAL from WCS: {}" . format ( ex ) ) logging . debug ( "Trying RA/DEC values" ) try : return ( float ( self [ 'RA-DEG' ] ) , float ( self [ 'DEC-DEG' ] ) ) except KeyError as ke : KeyErr... | Get the world coordinate of the reference pixel . |
47,741 | def pixscale ( self ) : try : ( x , y ) = self [ 'NAXIS1' ] / 2.0 , self [ 'NAXIS2' ] / 2.0 p1 = SkyCoord ( * self . wcs . xy2sky ( x , y ) * units . degree ) p2 = SkyCoord ( * self . wcs . xy2sky ( x + 1 , y + 1 ) * units . degree ) return round ( p1 . separation ( p2 ) . to ( units . arcsecond ) . value / math . sqrt... | Return the pixel scale of the detector in arcseconds . |
47,742 | def get_rates ( file , au_min = 25 , au_max = 150 ) : import os , string rate_command = 'rate.pl --file %s %d ' % ( file , au_min ) rate = os . popen ( rate_command ) line = rate . readline ( ) print line rate . close ( ) ( min_rate , min_ang , min_aw , min_rmin , min_rmax ) = string . split ( line ) rate_command = 'ra... | Use the rates program to determine the minimum and maximum bounds for planting |
47,743 | def kbo_gen ( file , outfile = 'objects.list' , mmin = 22.5 , mmax = 24.5 ) : header = get_rates ( file ) print header import pyfits hdulist = pyfits . open ( file ) header [ 'xmin' ] = 1 header [ 'xmax' ] = hdulist [ 0 ] . header . get ( 'NAXIS1' , 2048 ) header [ 'ymin' ] = 1 header [ 'aw' ] = round ( header [ 'aw' ]... | Generate a file with object moving at a range of rates and angles |
47,744 | def main ( ) : parser = argparse . ArgumentParser ( description = 'Run SSOIS and return the available images in a particular filter.' ) parser . add_argument ( "--filter" , action = "store" , default = 'r' , dest = "filter" , choices = [ 'r' , 'u' ] , help = "Passband: default is r." ) parser . add_argument ( "--family... | Input asteroid family filter type and image type to query SSOIS |
47,745 | def get_family_info ( familyname , filtertype = 'r' , imagetype = 'p' ) : family_list = '{}/{}_family.txt' . format ( _FAMILY_LISTS , familyname ) if os . path . exists ( family_list ) : with open ( family_list ) as infile : filestr = infile . read ( ) object_list = filestr . split ( '\n' ) elif familyname == 'all' : o... | Query the ssois table for images of objects in a given family . Then parse through for desired image type filter exposure time and telescope instrument |
47,746 | def get_member_info ( object_name , filtertype = 'r' , imagetype = 'p' ) : if filtertype . lower ( ) . __contains__ ( 'r' ) : filtertype = 'r.MP9601' if filtertype . lower ( ) . __contains__ ( 'u' ) : filtertype = 'u.MP9301' search_start_date = Time ( '2013-01-01' , scale = 'utc' ) search_end_date = Time ( '2017-01-01'... | Query the ssois table for images of a given object . Then parse through for desired image type filter exposure time and telescope instrument |
47,747 | def parse_ssois_return ( ssois_return , object_name , imagetype , camera_filter = 'r.MP9601' , telescope_instrument = 'CFHT/MegaCam' ) : assert camera_filter in [ 'r.MP9601' , 'u.MP9301' ] ret_table = [ ] good_table = 0 table_reader = ascii . get_reader ( Reader = ascii . Basic ) table_reader . inconsistent_handler = _... | Parse through objects in ssois query and filter out images of desired filter type exposure time and instrument |
47,748 | def match_mopfiles ( mopfile1 , mopfile2 ) : pos1 = pos2 = numpy . array ( [ ] ) if len ( mopfile1 . data ) > 0 : X_COL = "X_{}" . format ( mopfile1 . header . file_ids [ 0 ] ) Y_COL = "Y_{}" . format ( mopfile1 . header . file_ids [ 0 ] ) pos1 = numpy . array ( [ mopfile1 . data [ X_COL ] . data , mopfile1 . data [ Y_... | Given an input list of real detections and candidate detections provide a result file that contains the measured values from candidate detections with a flag indicating if they are real or false . |
47,749 | def measure_mags ( measures ) : import daophot image_downloader = ImageDownloader ( ) observations = { } for measure in measures : for reading in measure : if reading . obs not in observations : observations [ reading . obs ] = { 'x' : [ ] , 'y' : [ ] , 'source' : image_downloader . download ( reading , needs_apcor = T... | Given a list of readings compute the magnitudes for all sources in each reading . |
47,750 | def append ( self , item ) : if len ( self ) == 0 : self . index = 0 self . items . append ( item ) | Adds a new item to the end of the collection . |
47,751 | def fix_tags_on_cands_missing_reals ( user_id , vos_dir , property ) : "At the moment this just checks for a single user's missing reals. Easy to generalise it to all users." con = context . get_context ( vos_dir ) user_progress = [ ] listing = con . get_listing ( tasks . get_suffix ( 'reals' ) ) mpc_listing = con . ge... | At the moment this just checks for a single user s missing reals . Easy to generalise it to all users . |
47,752 | def make_error ( self , message : str , * , error : Exception = None , error_class : Any = None ) -> Exception : if error_class is None : error_class = self . error_class if self . error_class else Error return error_class ( message ) | Return error instantiated from given message . |
47,753 | def make_response ( self , data : Any = None , ** kwargs : Any ) -> Any : r if not self . _valid_request : logger . error ( 'Request not validated, cannot make response' ) raise self . make_error ( 'Request not validated before, cannot make ' 'response' ) if data is None and self . response_factory is None : logger . e... | r Validate response data and wrap it inside response factory . |
47,754 | def validate_request ( self , data : Any , * additional : AnyMapping , merged_class : Type [ dict ] = dict ) -> Any : r request_schema = getattr ( self . module , 'request' , None ) if request_schema is None : logger . error ( 'Request schema should be defined' , extra = { 'schema_module' : self . module , 'schema_modu... | r Validate request data against request schema from module . |
47,755 | def _merge_data ( self , data : AnyMapping , * additional : AnyMapping ) -> dict : r return defaults ( dict ( data ) if not isinstance ( data , dict ) else data , * ( dict ( item ) for item in additional ) ) | r Merge base data and additional dicts . |
47,756 | def _pure_data ( self , data : Any ) -> Any : if not isinstance ( data , dict ) and not isinstance ( data , list ) : try : return dict ( data ) except TypeError : ... return data | If data is dict - like object convert it to pure dict instance so it will be possible to pass to default jsonschema . validate func . |
47,757 | def _validate ( self , data : Any , schema : AnyMapping ) -> Any : try : return self . validate_func ( schema , self . _pure_data ( data ) ) except self . validation_error_class as err : logger . error ( 'Schema validation error' , exc_info = True , extra = { 'schema' : schema , 'schema_module' : self . module } ) if s... | Validate data against given schema . |
47,758 | def getCert ( certHost = vos . vos . SERVER , certfile = None , certQuery = "/cred/proxyCert?daysValid=" , daysValid = 2 ) : if certfile is None : certfile = os . path . join ( os . getenv ( "HOME" , "/tmp" ) , ".ssl/cadcproxy.pem" ) dirname = os . path . dirname ( certfile ) try : os . makedirs ( dirname ) except OSEr... | Access the cadc certificate server |
47,759 | def to_bool ( value : Any ) -> bool : return bool ( strtobool ( value ) if isinstance ( value , str ) else value ) | Convert string or other Python object to boolean . |
47,760 | def to_int ( value : str , default : T = None ) -> Union [ int , Optional [ T ] ] : try : return int ( value ) except ( TypeError , ValueError ) : return default | Convert given value to int . |
47,761 | def mk_dict ( results , description ) : rows = [ ] for row in results : row_dict = { } for idx in range ( len ( row ) ) : col = description [ idx ] [ 0 ] row_dict [ col ] = row [ idx ] rows . append ( row_dict ) return rows | Given a result list and descrition sequence return a list of dictionaries |
47,762 | def get_orbits ( official = '%' ) : sql = "SELECT * FROM orbits WHERE official LIKE '%s' " % ( official , ) cfeps . execute ( sql ) return mk_dict ( cfeps . fetchall ( ) , cfeps . description ) | Query the orbit table for the object whose official desingation matches parameter official . By default all entries are returned |
47,763 | def get_astrom ( official = '%' , provisional = '%' ) : sql = "SELECT m.* FROM measure m " sql += "LEFT JOIN object o ON m.provisional LIKE o.provisional " if not official : sql += "WHERE o.official IS NULL" else : sql += "WHERE o.official LIKE '%s' " % ( official , ) sql += " AND m.provisional LIKE '%s' " % ( provisi... | Query the measure table for all measurements of a particular object . Default is to return all the astrometry in the measure table sorted by mjdate |
47,764 | def getData ( file_id , ra , dec ) : DATA = "www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca" BASE = "http://" + DATA + "/authProxy/getData" archive = "CFHT" wcs = "corrected" import re groups = re . match ( '^(?P<file_id>\d{6}).*' , file_id ) if not groups : return None file_id = groups . group ( 'file_id' ) file_id += "p" URL =... | Create a link that connects to a getData URL |
47,765 | def delete_event ( self , uid ) : ev_for_deletion = self . calendar . get ( uid ) ev_for_deletion . delete ( ) | Delete event and sync calendar |
47,766 | def simple_lmdb_settings ( path , map_size = 1e9 , user_supplied_id = False ) : def decorator ( cls ) : provider = ff . UserSpecifiedIdProvider ( key = '_id' ) if user_supplied_id else ff . UuidProvider ( ) class Settings ( ff . PersistenceSettings ) : id_provider = provider key_builder = ff . StringDelimitedKeyBuilder... | Creates a decorator that can be used to configure sane default LMDB persistence settings for a model |
47,767 | def offset ( self , index = 0 ) : eta = self . _geometry [ self . camera ] [ index ] [ "ra" ] xi = self . _geometry [ self . camera ] [ index ] [ "dec" ] ra = self . origin . ra - ( eta / math . cos ( self . dec . radian ) ) * units . degree dec = self . origin . dec - xi * units . degree + 45 * units . arcsec self . _... | Offset the camera pointing to be centred on a particular CCD . |
47,768 | def coord ( self ) : if self . _coordinate is None : self . _coordinate = SkyCoord ( self . origin . ra , self . origin . dec + 45 * units . arcsec ) return self . _coordinate | The center of the camera pointing in sky coordinates |
47,769 | def requires_lock ( function ) : def new_lock_requiring_function ( self , filename , * args , ** kwargs ) : if self . owns_lock ( filename ) : return function ( self , filename , * args , ** kwargs ) else : raise RequiresLockException ( ) return new_lock_requiring_function | Decorator to check if the user owns the required lock . The first argument must be the filename . |
47,770 | def clean ( self , suffixes = None ) : if suffixes is None : suffixes = [ DONE_SUFFIX , LOCK_SUFFIX , PART_SUFFIX ] for suffix in suffixes : listing = self . working_context . get_listing ( suffix ) for filename in listing : self . working_context . remove ( filename ) | Remove all persistence - related files from the directory . |
47,771 | def setFigForm ( ) : fig_width_pt = 245.26 * 2 inches_per_pt = 1.0 / 72.27 golden_mean = ( math . sqrt ( 5. ) - 1.0 ) / 2.0 fig_width = fig_width_pt * inches_per_pt fig_height = fig_width * golden_mean fig_size = [ 1.5 * fig_width , fig_height ] params = { 'backend' : 'ps' , 'axes.labelsize' : 12 , 'text.fontsize' : 12... | set the rcparams to EmulateApJ columnwidth = 245 . 26 pts |
47,772 | def getCert ( username , password , certHost = _SERVER , certfile = None , certQuery = _PROXY ) : if certfile is None : certfile = tempfile . NamedTemporaryFile ( ) password_mgr = urllib2 . HTTPPasswordMgrWithDefaultRealm ( ) top_level_url = "http://" + certHost logging . debug ( top_level_url ) password_mgr . add_pass... | Access the cadc certificate server . |
47,773 | def getGroupsURL ( certfile , group ) : GMS = "https://" + _SERVER + _GMS certfile . seek ( 0 ) buf = certfile . read ( ) x509 = crypto . load_certificate ( crypto . FILETYPE_PEM , buf ) sep = "" dn = "" parts = [ ] for i in x509 . get_issuer ( ) . get_components ( ) : if i [ 0 ] in parts : continue parts . append ( i ... | given a certfile load a list of groups that user is a member of |
47,774 | def stub ( ) : form = cgi . FieldStorage ( ) userid = form [ 'userid' ] . value password = form [ 'passwd' ] . value group = form [ 'group' ] . value | Just some left over code |
47,775 | def parse_pv ( header ) : order_fit = parse_order_fit ( header ) def parse_with_base ( i ) : key_base = "PV%d_" % i pvi_x = [ header [ key_base + "0" ] ] def parse_range ( lower , upper ) : for j in range ( lower , upper + 1 ) : pvi_x . append ( header [ key_base + str ( j ) ] ) if order_fit >= 1 : parse_range ( 1 , 3 ... | Parses the PV array from an astropy FITS header . |
47,776 | def safe_unit_norm ( a ) : if 1 == len ( a . shape ) : n = np . linalg . norm ( a ) if n : return a / n return a norm = np . sum ( np . abs ( a ) ** 2 , axis = - 1 ) ** ( 1. / 2 ) norm [ norm == 0 ] = - 1e12 return a / norm [ : , np . newaxis ] | Ensure that the vector or vectors have unit norm |
47,777 | def pad ( a , desiredlength ) : if len ( a ) >= desiredlength : return a islist = isinstance ( a , list ) a = np . array ( a ) diff = desiredlength - len ( a ) shape = list ( a . shape ) shape [ 0 ] = diff padded = np . concatenate ( [ a , np . zeros ( shape , dtype = a . dtype ) ] ) return padded . tolist ( ) if islis... | Pad an n - dimensional numpy array with zeros along the zero - th dimension so that it is the desired length . Return it unchanged if it is greater than or equal to the desired length |
47,778 | def append ( self , item ) : try : self . _data [ self . _position ] = item except IndexError : self . _grow ( ) self . _data [ self . _position ] = item self . _position += 1 return self | append a single item to the array growing the wrapped numpy array if necessary |
47,779 | def extend ( self , items ) : items = np . array ( items ) pos = items . shape [ 0 ] + self . logical_size if pos > self . physical_size : amt = self . _tmp_size ( ) if self . physical_size + amt < pos : amt = pos - self . physical_size self . _grow ( amt = amt ) stop = self . _position + items . shape [ 0 ] self . _da... | extend the numpy array with multiple items growing the wrapped array if necessary |
47,780 | def align ( self , cutout , reading , source ) : if not self . current_displayable : return if not self . current_displayable . aligned : focus_sky_coord = reading . reference_sky_coord self . current_displayable . pan_to ( focus_sky_coord ) | Set the display center to the reference point . |
47,781 | def phot_mag ( * args , ** kwargs ) : try : return phot ( * args , ** kwargs ) except IndexError : raise TaskError ( "No photometric records returned for {0}" . format ( kwargs ) ) | Wrapper around phot which only returns the computed magnitude directly . |
47,782 | def from_env ( key : str , default : T = None ) -> Union [ str , Optional [ T ] ] : return os . getenv ( key , default ) | Shortcut for safely reading environment variable . |
47,783 | def immutable_settings ( defaults : Settings , ** optionals : Any ) -> types . MappingProxyType : r settings = { key : value for key , value in iter_settings ( defaults ) } for key , value in iter_settings ( optionals ) : settings [ key ] = value return types . MappingProxyType ( settings ) | r Initialize and return immutable Settings dictionary . |
47,784 | def inject_settings ( mixed : Union [ str , Settings ] , context : MutableMapping [ str , Any ] , fail_silently : bool = False ) -> None : if isinstance ( mixed , str ) : try : mixed = import_module ( mixed ) except Exception : if fail_silently : return raise for key , value in iter_settings ( mixed ) : context [ key ]... | Inject settings values to given context . |
47,785 | def iter_settings ( mixed : Settings ) -> Iterator [ Tuple [ str , Any ] ] : if isinstance ( mixed , types . ModuleType ) : for attr in dir ( mixed ) : if not is_setting_key ( attr ) : continue yield ( attr , getattr ( mixed , attr ) ) else : yield from filter ( lambda item : is_setting_key ( item [ 0 ] ) , mixed . ite... | Iterate over settings values from settings module or dict - like instance . |
47,786 | def setup_locale ( lc_all : str , first_weekday : int = None , * , lc_collate : str = None , lc_ctype : str = None , lc_messages : str = None , lc_monetary : str = None , lc_numeric : str = None , lc_time : str = None ) -> str : if first_weekday is not None : calendar . setfirstweekday ( first_weekday ) locale . setloc... | Shortcut helper to setup locale for backend application . |
47,787 | def setup_timezone ( timezone : str ) -> None : if timezone and hasattr ( time , 'tzset' ) : tz_root = '/usr/share/zoneinfo' tz_filename = os . path . join ( tz_root , * ( timezone . split ( '/' ) ) ) if os . path . exists ( tz_root ) and not os . path . exists ( tz_filename ) : raise ValueError ( 'Incorrect timezone v... | Shortcut helper to configure timezone for backend application . |
47,788 | def inputs ( header ) : import string , re inputs = [ ] for h in header . ascardlist ( ) : if h . key == "HISTORY" : g = h . value result = re . search ( 'imcombred: (\d{6}[bfopd])\d{2} .*' , g ) if not result : continue file_id = result . group ( 1 ) import os status = os . system ( "adInfo -a CFHT -s " + file_id ) if... | Read through the HISTORY cards in an image header looking for detrend input lines . |
47,789 | def elixir_decode ( elixir_filename ) : import re , pyfits parts_RE = re . compile ( r'([^\.\s]+)' ) dataset_name = parts_RE . findall ( elixir_filename ) if not dataset_name or len ( dataset_name ) < 5 : raise ValueError ( 'String %s does not parse as elixir filename' % elixir_filename ) comments = { 'exptime' : 'Inte... | Takes an elixir style file name and decodes it s content . |
47,790 | def create_mef ( filename = None ) : import pyfits , time if not filename : import tempfile filename = tempfile . mktemp ( suffix = '.fits' ) else : import string , re filename = string . strip ( str ( filename ) ) suffix = re . match ( r'^.*.fits$' , filename ) if not suffix : filename = filename + '.fits' temp = pyfi... | Create a file an MEF fits file called filename . Generate a random filename if None given |
47,791 | def strip_pad ( hdu ) : l = hdu . header . ascardlist ( ) d = [ ] for index in range ( len ( l ) ) : if l [ index ] . key in __comment_keys and str ( l [ index ] ) == __cfht_padding : d . append ( index ) d . reverse ( ) for index in d : del l [ index ] return ( 0 ) | Remove the padding lines that CFHT adds to headers |
47,792 | def stack ( outfile , infiles , verbose = 0 ) : import os , sys , string , tempfile , shutil import pyfits , re , time if os . access ( outfile , os . R_OK ) != 1 : if verbose : print "Creating new MEF file: " , outfile outfile = create_mef ( outfile ) out = pyfits . open ( outfile , 'append' ) hdr = out [ 0 ] . header... | Stick infiles into outfiles as FITS extensions . |
47,793 | def adGet ( file_id , archive = "CFHT" , extno = None , cutout = None ) : import os , string , re , urllib proxy = "http://test.cadc-ccda.hia-iha.nrc-cnrc.gc.ca/authProxy/getData" if file_id is None : return ( - 1 ) if extno is None : filename = file_id + ".fits" else : filename = "%s%s.fits" % ( file_id , string . zfi... | Use get a fits image from the CADC . |
47,794 | def _open ( file , mode = 'copyonwrite' ) : import pyfits try : infits = pyfits . open ( file , mode ) hdu = infits except ( ValueError , pyfits . VerifyError , pyfits . FITS_SevereError ) : import sys hdu = _open_fix ( file ) for f in hdu : strip_pad ( f ) return hdu | Opens a FITS format file and calls _open_fix if header doesn t verify correctly . |
47,795 | def find_proc_date ( header ) : import string , re for h in header . ascardlist ( ) : if h . key == "HISTORY" : g = h . value if ( string . find ( g , 'FLIPS 1.0 -:' ) ) : result = re . search ( 'imred: FLIPS 1.0 - \S{3} (.*) - ([\s\d]\d:\d\d:\d\d)\s*$' , g ) if result : date = result . group ( 1 ) time = result . grou... | Search the HISTORY fields of a header looking for the FLIPS processing date . |
47,796 | def build_source_reading ( expnum , ccd = None , ftype = 'p' ) : logger . debug ( "Building source reading for expnum:{} ccd:{} ftype:{}" . format ( expnum , ccd , ftype ) ) return astrom . Observation ( expnum = str ( expnum ) , ftype = ftype , ccdnum = ccd ) | Build an astrom . Observation object for a SourceReading |
47,797 | def recenter ( self ) : if self . ctype1 . find ( 'TAN' ) < 0 or self . ctype2 . find ( 'TAN' ) < 0 : print 'WCS.recenter() only supported for TAN projections.' raise TypeError if self . crpix1 == self . naxis1 / 2. and self . crpix2 == self . naxis2 / 2. : return _drz_off = 0. _cen = ( self . naxis1 / 2. + _drz_off , ... | Reset the reference position values to correspond to the center of the reference frame . Algorithm used here developed by Colin Cox - 27 - Jan - 2004 . |
47,798 | def _buildNewKeyname ( self , key , prepend ) : if len ( prepend + key ) <= 8 : _new_key = prepend + key else : _new_key = str ( prepend + key ) [ : 8 ] return _new_key | Builds a new keyword based on original keyword name and a prepend string . |
47,799 | def ushort ( filename ) : import pyfits f = pyfits . open ( filename , mode = 'update' ) f [ 0 ] . scale ( 'int16' , '' , bzero = 32768 ) f . flush ( ) f . close ( ) | Ushort a the pixels |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.