idx int64 0 63k | question stringlengths 53 5.28k | target stringlengths 5 805 |
|---|---|---|
47,900 | def reset_coord ( self ) : ( x , y , idx ) = self . world2pix ( self . init_skycoord . ra , self . init_skycoord . dec , usepv = True ) self . update_pixel_location ( ( x , y ) , idx ) | Reset the source location based on the init_skycoord values |
47,901 | def pixel_coord ( self ) : return self . get_pixel_coordinates ( self . reading . pix_coord , self . reading . get_ccd_num ( ) ) | Return the coordinates of the source in the cutout reference frame . |
47,902 | def get_pixel_coordinates ( self , point , ccdnum ) : hdulist_index = self . get_hdulist_idx ( ccdnum ) if isinstance ( point [ 0 ] , Quantity ) and isinstance ( point [ 1 ] , Quantity ) : pix_point = point [ 0 ] . value , point [ 1 ] . value else : pix_point = point if self . reading . inverted : pix_point = self . re... | Retrieves the pixel location of a point within the current HDUList given the location in the original FITS image . This takes into account that the image may be a cutout of a larger original . |
47,903 | def get_observation_coordinates ( self , x , y , hdulist_index ) : return self . hdulist [ hdulist_index ] . converter . get_inverse_converter ( ) . convert ( ( x , y ) ) | Retrieves the location of a point using the coordinate system of the original observation i . e . the original image before any cutouts were done . |
47,904 | def zmag ( self , ) : if self . _zmag is None : hdulist_index = self . get_hdulist_idx ( self . reading . get_ccd_num ( ) ) self . _zmag = self . hdulist [ hdulist_index ] . header . get ( 'PHOTZP' , 0.0 ) return self . _zmag | Return the photometric zeropoint of the CCD associated with the reading . |
47,905 | def apcor ( self ) : if self . _apcor is None : try : self . _apcor = Downloader ( ) . download_apcor ( self . reading . get_apcor_uri ( ) ) except : self . _apcor = ApcorData . from_string ( "5 15 99.99 99.99" ) return self . _apcor | return the aperture correction of for the CCD assocated with the reading . |
47,906 | def _hdu_on_disk ( self , hdulist_index ) : if self . _tempfile is None : self . _tempfile = tempfile . NamedTemporaryFile ( mode = "r+b" , suffix = ".fits" ) self . hdulist [ hdulist_index ] . writeto ( self . _tempfile . name ) return self . _tempfile . name | IRAF routines such as daophot need input on disk . |
47,907 | def comparison_image_list ( self ) : if self . _comparison_image_list is not None : return self . _comparison_image_list ref_ra = self . reading . ra * units . degree ref_dec = self . reading . dec * units . degree radius = self . radius is not None and self . radius or config . read ( 'CUTOUTS.SINGLETS.RADIUS' ) * uni... | returns a list of possible comparison images for the current cutout . Will query CADC to create the list when first called . |
47,908 | def retrieve_comparison_image ( self ) : collectionID = self . comparison_image_list [ self . comparison_image_index ] [ 'EXPNUM' ] ref_ra = self . reading . ra * units . degree ref_dec = self . reading . dec * units . degree radius = self . radius is not None and self . radius or config . read ( 'CUTOUTS.SINGLETS.RADI... | Search the DB for a comparison image for this cutout . |
47,909 | def check_password ( self , passwd , group ) : return gms . isMember ( self . login , passwd , group ) | check that the passwd provided matches the required password . |
47,910 | def plant ( expnums , ccd , rmin , rmax , ang , width , number = 10 , mmin = 21.0 , mmax = 25.5 , version = 's' , dry_run = False ) : filename = storage . get_image ( expnums [ 0 ] , ccd = ccd , version = version ) header = fits . open ( filename ) [ 0 ] . header bounds = util . get_pixel_bounds_from_datasec_keyword ( ... | Plant artificial sources into the list of images provided . |
47,911 | def _fit_radec ( self ) : self . orbfit . fitradec . restype = ctypes . c_int self . orbfit . fitradec . argtypes = [ ctypes . c_char_p , ctypes . c_char_p , ctypes . c_char_p ] mpc_file = tempfile . NamedTemporaryFile ( suffix = '.mpc' ) for observation in self . observations : mpc_file . write ( "{}\n" . format ( str... | call fit_radec of BK passing in the observations . |
47,912 | def predict ( self , date , obs_code = 568 ) : time = Time ( date , scale = 'utc' , precision = 6 ) jd = ctypes . c_double ( time . jd ) self . orbfit . predict . restype = ctypes . POINTER ( ctypes . c_double * 5 ) self . orbfit . predict . argtypes = [ ctypes . c_char_p , ctypes . c_double , ctypes . c_int ] predict ... | use the bk predict method to compute the location of the source on the given date . |
47,913 | def write ( file , hdu , order = None , format = None ) : if order or format : warnings . warn ( 'Use of <order> and <format> depricated' , DeprecationWarning ) data = 'data' if not order : if not hdu . has_key ( 'order' ) : hdu [ 'order' ] = hdu [ data ] . keys ( ) else : hdu [ 'order' ] = order if not format : if not... | Write a file in the crazy MOP format given an mop data hdu . |
47,914 | def read ( file ) : f = open ( file , 'r' ) lines = f . readlines ( ) f . close ( ) import re , string keywords = [ ] values = [ ] formats = { } header = { } cdata = { } for line in lines : if ( re . match ( r'^##' , line ) ) : m = string . split ( string . lstrip ( line [ 2 : ] ) ) if not m : sys . stderr . write ( "I... | Read in a file and create a data strucuture that is a hash with members header and data . The header is a hash of header keywords the data is a hash of columns . |
47,915 | def default_logging_dict ( * loggers : str , ** kwargs : Any ) -> DictStrAny : r kwargs . setdefault ( 'level' , 'INFO' ) return { 'version' : 1 , 'disable_existing_loggers' : True , 'filters' : { 'ignore_errors' : { '()' : IgnoreErrorsFilter , } , } , 'formatters' : { 'default' : { 'format' : '%(asctime)s [%(levelname... | r Prepare logging dict suitable with logging . config . dictConfig . |
47,916 | def update_sentry_logging ( logging_dict : DictStrAny , sentry_dsn : Optional [ str ] , * loggers : str , level : Union [ str , int ] = None , ** kwargs : Any ) -> None : r if not sentry_dsn : return kwargs [ 'class' ] = 'raven.handlers.logging.SentryHandler' kwargs [ 'dsn' ] = sentry_dsn logging_dict [ 'handlers' ] [ ... | r Enable Sentry logging if Sentry DSN passed . |
47,917 | def ossos_release_parser ( table = False , data_release = parameters . RELEASE_VERSION ) : names = [ 'cl' , 'p' , 'j' , 'k' , 'sh' , 'object' , 'mag' , 'e_mag' , 'Filt' , 'Hsur' , 'dist' , 'e_dist' , 'Nobs' , 'time' , 'av_xres' , 'av_yres' , 'max_x' , 'max_y' , 'a' , 'e_a' , 'e' , 'e_e' , 'i' , 'e_i' , 'Omega' , 'e_Ome... | extra fun as this is space - separated so using CSV parsers is not an option |
47,918 | def ossos_discoveries ( directory = parameters . REAL_KBO_AST_DIR , suffix = 'ast' , no_nt_and_u = False , single_object = None , all_objects = True , data_release = None , ) : retval = [ ] files = [ f for f in os . listdir ( directory ) if ( f . endswith ( 'mpc' ) or f . endswith ( 'ast' ) or f . endswith ( 'DONE' ) )... | Returns a list of objects holding orbfit . Orbfit objects with the observations in the Orbfit . observations field . Default is to return only the objects corresponding to the current Data Release . |
47,919 | def ossos_release_with_metadata ( ) : discoveries = [ ] observations = ossos_discoveries ( ) for obj in observations : discov = [ n for n in obj [ 0 ] . mpc_observations if n . discovery . is_discovery ] [ 0 ] tno = parameters . tno ( ) tno . dist = obj [ 1 ] . distance tno . ra_discov = discov . coordinate . ra . degr... | Wrap the objects from the Version Releases together with the objects instantiated from fitting their mpc lines |
47,920 | def _kbos_from_survey_sym_model_input_file ( model_file ) : lines = storage . open_vos_or_local ( model_file ) . read ( ) . split ( '\n' ) kbos = [ ] for line in lines : if len ( line ) == 0 or line [ 0 ] == '#' : continue kbo = ephem . EllipticalBody ( ) values = line . split ( ) kbo . name = values [ 8 ] kbo . j = va... | Load a Survey Simulator model file as an array of ephem EllipticalBody objects . |
47,921 | def _parse_elcm_response_body_as_json ( response ) : try : body = response . text body_parts = body . split ( '\r\n' ) if len ( body_parts ) > 0 : return jsonutils . loads ( body_parts [ - 1 ] ) else : return None except ( TypeError , ValueError ) : raise ELCMInvalidResponse ( 'eLCM response does not contain valid json... | parse eLCM response body as json data |
47,922 | def elcm_request ( irmc_info , method , path , ** kwargs ) : host = irmc_info [ 'irmc_address' ] port = irmc_info . get ( 'irmc_port' , 443 ) auth_method = irmc_info . get ( 'irmc_auth_method' , 'basic' ) userid = irmc_info [ 'irmc_username' ] password = irmc_info [ 'irmc_password' ] client_timeout = irmc_info . get ( ... | send an eLCM request to the server |
47,923 | def elcm_profile_get_versions ( irmc_info ) : resp = elcm_request ( irmc_info , method = 'GET' , path = URL_PATH_PROFILE_MGMT + 'version' ) if resp . status_code == 200 : return _parse_elcm_response_body_as_json ( resp ) else : raise scci . SCCIClientError ( ( 'Failed to get profile versions with ' 'error code %s' % re... | send an eLCM request to get profile versions |
47,924 | def elcm_profile_get ( irmc_info , profile_name ) : resp = elcm_request ( irmc_info , method = 'GET' , path = URL_PATH_PROFILE_MGMT + profile_name ) if resp . status_code == 200 : return _parse_elcm_response_body_as_json ( resp ) elif resp . status_code == 404 : raise ELCMProfileNotFound ( 'Profile "%s" not found ' 'in... | send an eLCM request to get profile data |
47,925 | def elcm_profile_create ( irmc_info , param_path ) : _irmc_info = dict ( irmc_info ) _irmc_info [ 'irmc_client_timeout' ] = PROFILE_CREATE_TIMEOUT resp = elcm_request ( _irmc_info , method = 'POST' , path = URL_PATH_PROFILE_MGMT + 'get' , params = { 'PARAM_PATH' : param_path } ) if resp . status_code == 202 : return _p... | send an eLCM request to create profile |
47,926 | def elcm_profile_set ( irmc_info , input_data ) : if isinstance ( input_data , dict ) : data = jsonutils . dumps ( input_data ) else : data = input_data _irmc_info = dict ( irmc_info ) _irmc_info [ 'irmc_client_timeout' ] = PROFILE_SET_TIMEOUT content_type = 'application/x-www-form-urlencoded' if input_data [ 'Server' ... | send an eLCM request to set param values |
47,927 | def elcm_profile_delete ( irmc_info , profile_name ) : resp = elcm_request ( irmc_info , method = 'DELETE' , path = URL_PATH_PROFILE_MGMT + profile_name ) if resp . status_code == 200 : return elif resp . status_code == 404 : raise ELCMProfileNotFound ( 'Profile "%s" not found ' 'in the profile store.' % profile_name )... | send an eLCM request to delete a profile |
47,928 | def elcm_session_list ( irmc_info ) : resp = elcm_request ( irmc_info , method = 'GET' , path = '/sessionInformation/' ) if resp . status_code == 200 : return _parse_elcm_response_body_as_json ( resp ) else : raise scci . SCCIClientError ( ( 'Failed to list sessions with ' 'error code %s' % resp . status_code ) ) | send an eLCM request to list all sessions |
47,929 | def elcm_session_get_status ( irmc_info , session_id ) : resp = elcm_request ( irmc_info , method = 'GET' , path = '/sessionInformation/%s/status' % session_id ) if resp . status_code == 200 : return _parse_elcm_response_body_as_json ( resp ) elif resp . status_code == 404 : raise ELCMSessionNotFound ( 'Session "%s" do... | send an eLCM request to get session status |
47,930 | def elcm_session_terminate ( irmc_info , session_id ) : resp = elcm_request ( irmc_info , method = 'DELETE' , path = '/sessionInformation/%s/terminate' % session_id ) if resp . status_code == 200 : return elif resp . status_code == 404 : raise ELCMSessionNotFound ( 'Session "%s" does not exist' % session_id ) else : ra... | send an eLCM request to terminate a session |
47,931 | def elcm_session_delete ( irmc_info , session_id , terminate = False ) : if terminate : session = elcm_session_get_status ( irmc_info , session_id ) status = session [ 'Session' ] [ 'Status' ] if status == 'running' or status == 'activated' : elcm_session_terminate ( irmc_info , session_id ) resp = elcm_request ( irmc_... | send an eLCM request to remove a session from the session list |
47,932 | def backup_bios_config ( irmc_info ) : try : elcm_profile_get ( irmc_info = irmc_info , profile_name = PROFILE_BIOS_CONFIG ) elcm_profile_delete ( irmc_info = irmc_info , profile_name = PROFILE_BIOS_CONFIG ) except ELCMProfileNotFound : pass session = elcm_profile_create ( irmc_info = irmc_info , param_path = PARAM_PAT... | backup current bios configuration |
47,933 | def restore_bios_config ( irmc_info , bios_config ) : def _process_bios_config ( ) : try : if isinstance ( bios_config , dict ) : input_data = bios_config else : input_data = jsonutils . loads ( bios_config ) bios_cfg = input_data [ 'Server' ] [ 'SystemConfig' ] [ 'BiosConfig' ] bios_cfg [ '@Processing' ] = 'execute' r... | restore bios configuration |
47,934 | def get_secure_boot_mode ( irmc_info ) : result = backup_bios_config ( irmc_info = irmc_info ) try : bioscfg = result [ 'bios_config' ] [ 'Server' ] [ 'SystemConfig' ] [ 'BiosConfig' ] return bioscfg [ 'SecurityConfig' ] [ 'SecureBootControlEnabled' ] except KeyError : msg = ( "Failed to get secure boot mode from serve... | Get the status if secure boot is enabled or not . |
47,935 | def _update_raid_input_data ( target_raid_config , raid_input ) : logical_disk_list = target_raid_config [ 'logical_disks' ] raid_input [ 'Server' ] [ 'HWConfigurationIrmc' ] . update ( { '@Processing' : 'execute' } ) array_info = raid_input [ 'Server' ] [ 'HWConfigurationIrmc' ] [ 'Adapters' ] [ 'RAIDAdapter' ] [ 0 ] ... | Process raid input data . |
47,936 | def _get_existing_logical_drives ( raid_adapter ) : existing_logical_drives = [ ] logical_drives = raid_adapter [ 'Server' ] [ 'HWConfigurationIrmc' ] [ 'Adapters' ] [ 'RAIDAdapter' ] [ 0 ] . get ( 'LogicalDrives' ) if logical_drives is not None : for drive in logical_drives [ 'LogicalDrive' ] : existing_logical_drives... | Collect existing logical drives on the server . |
47,937 | def _create_raid_adapter_profile ( irmc_info ) : try : elcm_profile_delete ( irmc_info , PROFILE_RAID_CONFIG ) except ELCMProfileNotFound : pass session = elcm_profile_create ( irmc_info , PARAM_PATH_RAID_CONFIG ) session_timeout = irmc_info . get ( 'irmc_raid_session_timeout' , RAID_CONFIG_SESSION_TIMEOUT ) return _pr... | Attempt delete exist adapter then create new raid adapter on the server . |
47,938 | def create_raid_configuration ( irmc_info , target_raid_config ) : if len ( target_raid_config [ 'logical_disks' ] ) < 1 : raise ELCMValueError ( message = "logical_disks must not be empty" ) raid_adapter = get_raid_adapter ( irmc_info ) logical_drives = raid_adapter [ 'Server' ] [ 'HWConfigurationIrmc' ] [ 'Adapters' ... | Process raid_input then perform raid configuration into server . |
47,939 | def delete_raid_configuration ( irmc_info ) : raid_adapter = get_raid_adapter ( irmc_info ) existing_logical_drives = _get_existing_logical_drives ( raid_adapter ) if not existing_logical_drives : return raid_adapter [ 'Server' ] [ 'HWConfigurationIrmc' ] . update ( { '@Processing' : 'execute' } ) logical_drive = raid_... | Delete whole raid configuration or one of logical drive on the server . |
47,940 | def set_bios_configuration ( irmc_info , settings ) : bios_config_data = { 'Server' : { 'SystemConfig' : { 'BiosConfig' : { } } } } versions = elcm_profile_get_versions ( irmc_info ) server_version = versions [ 'Server' ] . get ( '@Version' ) bios_version = versions [ 'Server' ] [ 'SystemConfig' ] [ 'BiosConfig' ] . ge... | Set BIOS configurations on the server . |
47,941 | def get_bios_settings ( irmc_info ) : bios_config = backup_bios_config ( irmc_info ) [ 'bios_config' ] bios_config_data = bios_config [ 'Server' ] [ 'SystemConfig' ] [ 'BiosConfig' ] settings = [ ] for setting_param in BIOS_CONFIGURATION_DICTIONARY : type_config , config = BIOS_CONFIGURATION_DICTIONARY [ setting_param ... | Get the current BIOS settings on the server |
47,942 | def add_resource_context ( router : web . AbstractRouter , url_prefix : str = None , name_prefix : str = None ) -> Iterator [ Any ] : def add_resource ( url : str , get : View = None , * , name : str = None , ** kwargs : Any ) -> web . Resource : kwargs [ 'get' ] = get if url_prefix : url = '/' . join ( ( url_prefix . ... | Context manager for adding resources for given router . |
47,943 | def calculate_focus ( self , reading ) : middle_index = len ( self . source . get_readings ( ) ) // 2 middle_reading = self . source . get_reading ( middle_index ) return self . convert_source_location ( middle_reading , reading ) | Determines what the focal point of the downloaded image should be . |
47,944 | def plot_ossos_discoveries ( ax , discoveries , plot_discoveries , plot_colossos = False , split_plutinos = False ) : fc = [ 'b' , '#E47833' , 'k' ] alpha = [ 0.85 , 0.6 , 1. ] marker = [ 'o' , 'd' ] size = [ 7 , 25 ] plottable = [ ] for d in discoveries : for n in plot_discoveries : if d [ 'object' ] . startswith ( n ... | plotted at their discovery locations provided by the Version Releases in decimal degrees . |
47,945 | def get_irmc_firmware_version ( snmp_client ) : try : bmc_name = snmp_client . get ( BMC_NAME_OID ) irmc_firm_ver = snmp_client . get ( IRMC_FW_VERSION_OID ) return ( '%(bmc)s%(sep)s%(firm_ver)s' % { 'bmc' : bmc_name if bmc_name else '' , 'firm_ver' : irmc_firm_ver if irmc_firm_ver else '' , 'sep' : '-' if bmc_name and... | Get irmc firmware version of the node . |
47,946 | def get_bios_firmware_version ( snmp_client ) : try : bios_firmware_version = snmp_client . get ( BIOS_FW_VERSION_OID ) return six . text_type ( bios_firmware_version ) except SNMPFailure as e : raise SNMPBIOSFirmwareFailure ( SNMP_FAILURE_MSG % ( "GET BIOS FIRMWARE VERSION" , e ) ) | Get bios firmware version of the node . |
47,947 | def get_server_model ( snmp_client ) : try : server_model = snmp_client . get ( SERVER_MODEL_OID ) return six . text_type ( server_model ) except SNMPFailure as e : raise SNMPServerModelFailure ( SNMP_FAILURE_MSG % ( "GET SERVER MODEL" , e ) ) | Get server model of the node . |
47,948 | def _get_auth ( self ) : if self . version == SNMP_V3 : return cmdgen . UsmUserData ( self . security ) else : mp_model = 1 if self . version == SNMP_V2C else 0 return cmdgen . CommunityData ( self . community , mpModel = mp_model ) | Return the authorization data for an SNMP request . |
47,949 | def get ( self , oid ) : try : results = self . cmd_gen . getCmd ( self . _get_auth ( ) , self . _get_transport ( ) , oid ) except snmp_error . PySnmpError as e : raise SNMPFailure ( SNMP_FAILURE_MSG % ( "GET" , e ) ) error_indication , error_status , error_index , var_binds = results if error_indication : raise SNMPFa... | Use PySNMP to perform an SNMP GET operation on a single object . |
47,950 | def get_next ( self , oid ) : try : results = self . cmd_gen . nextCmd ( self . _get_auth ( ) , self . _get_transport ( ) , oid ) except snmp_error . PySnmpError as e : raise SNMPFailure ( SNMP_FAILURE_MSG % ( "GET_NEXT" , e ) ) error_indication , error_status , error_index , var_binds = results if error_indication : r... | Use PySNMP to perform an SNMP GET NEXT operation on a table object . |
47,951 | def set ( self , oid , value ) : try : results = self . cmd_gen . setCmd ( self . _get_auth ( ) , self . _get_transport ( ) , ( oid , value ) ) except snmp_error . PySnmpError as e : raise SNMPFailure ( SNMP_FAILURE_MSG % ( "SET" , e ) ) error_indication , error_status , error_index , var_binds = results if error_indic... | Use PySNMP to perform an SNMP SET operation on a single object . |
47,952 | def filename ( self ) : if self . _filename is None : self . _filename = storage . get_file ( self . basename , self . ccd , ext = self . extension , version = self . type , prefix = self . prefix ) return self . _filename | Name if the MOP formatted file to parse . |
47,953 | def _parse ( self ) : with open ( self . filename , 'r' ) as fobj : lines = fobj . read ( ) . split ( '\n' ) self . header = MOPHeader ( self . subfmt ) . parser ( lines ) self . data = MOPDataParser ( self . header ) . parse ( lines ) | read in a file and return a MOPFile object . |
47,954 | def table ( self ) : if self . _table is None : column_names = [ ] for fileid in self . header . file_ids : for column_name in self . header . column_names : column_names . append ( "{}_{}" . format ( column_name , fileid ) ) column_names . append ( "ZP_{}" . format ( fileid ) ) if len ( column_names ) > 0 : self . _ta... | The astropy . table . Table object that will contain the data result |
47,955 | def parser ( self , lines ) : while len ( lines ) > 0 : if lines [ 0 ] . startswith ( '##' ) and lines [ 1 ] . startswith ( '# ' ) : self . _header_append ( lines . pop ( 0 ) , lines . pop ( 0 ) ) elif lines [ 0 ] . startswith ( '# ' ) : self . _append_file_id ( lines . pop ( 0 ) ) elif lines [ 0 ] . startswith ( '##' ... | Given a set of lines parse the into a MOP Header |
47,956 | def _compute_mjd ( self , kw , val ) : try : idx = kw . index ( 'MJD-OBS-CENTER' ) except ValueError : return if len ( val ) == len ( kw ) : return if len ( val ) - 2 != len ( kw ) : raise ValueError ( "convert: keyword/value lengths don't match: {}/{}" . format ( kw , val ) ) val . insert ( idx , Time ( "{} {} {}" . f... | Sometimes that MJD - OBS - CENTER keyword maps to a three component string instead of a single value . |
47,957 | def getExpInfo ( expnum ) : col_names = [ 'object' , 'e.expnum' , 'mjdate' , 'uttime' , 'filter' , 'elongation' , 'obs_iq_refccd' , 'triple' , 'qso_status' ] sql = "SELECT " sep = " " for col_name in col_names : sql = sql + sep + col_name sep = "," sql = sql + " FROM bucket.exposure e " sql = sql + " JOIN bucket.circum... | Return a dictionary of information about a particular exposure |
47,958 | def getTripInfo ( triple ) : col_names = [ 'mjdate' , 'filter' , 'elongation' , 'discovery' , 'checkup' , 'recovery' , 'iq' , 'block' ] sql = "SELECT mjdate md," sql = sql + " filter, avg(elongation), d.id, checkup.checkup, recovery.recovery , avg(obs_iq_refccd), b.qname " sql = sql + "FROM triple_members t JOIN bucket... | Return a dictionary of information about a particular triple |
47,959 | def getExpnums ( pointing , night = None ) : if night : night = " floor(e.mjdate-0.0833)=%d " % ( night ) else : night = '' sql = "SELECT e.expnum " sql = sql + "FROM bucket.exposure e " sql = sql + "JOIN bucket.association a on e.expnum=a.expnum " sql = sql + "WHERE a.pointing=" + str ( pointing ) + " AND " + night sq... | Get all exposures of specified pointing ID . |
47,960 | def getTriples ( pointing ) : sql = "SELECT id FROM triples t join triple_members m ON t.id=m.triple" sql += " join bucket.exposure e on e.expnum=m.expnum " sql += " WHERE pointing=%s group by id order by e.expnum " cfeps . execute ( sql , ( pointing , ) ) return ( cfeps . fetchall ( ) ) | Get all triples of a specified pointing ID . |
47,961 | def createNewTriples ( Win ) : win . help ( "Building list of exposures to look for triples" ) cols = ( 'e.expnum' , 'object' , 'mjdate' , 'uttime' , 'elongation' , 'filter' , 'obs_iq_refccd' , 'qso_status' ) header = '%6s %-10s%-12s%10s%10s%10s%8s%10s' % cols pointings = getNewTriples ( ) num_p = len ( pointings ) for... | Add entries to the triples tables based on new images in the db |
47,962 | def setDiscoveryTriples ( win , table = "discovery" ) : win . help ( "Getting a list of pointings with triples from the CFEPS db" ) pointings = getPointingsWithTriples ( ) win . help ( "Select the " + table + " triple form the list..." ) import time for pointing in pointings : header = "%10s %10s %8s %10s %8s" % ( poin... | Provide user with a list of triples that could be discovery triples |
47,963 | def fits_list ( filter , root , fnames ) : import re , pyfits , wcsutil for file in fnames : if re . match ( filter , file ) : fh = pyfits . open ( file ) for ext in fh : obj = ext . header . get ( 'OBJECT' , file ) dx = ext . header . get ( 'NAXIS1' , None ) dy = ext . header . get ( 'NAXIS2' , None ) wcs = wcsutil . ... | Get a list of files matching filter in directory root |
47,964 | def load_fis ( dir = None ) : if dir is None : import tkFileDialog try : dir = tkFileDialog . askdirectory ( ) except : return if dir is None : return None from os . path import walk walk ( dir , fits_list , "*.fits" ) | Load fits images in a directory |
47,965 | def do_objs ( kbos ) : import orbfit , ephem , math import re re_string = w . FilterVar . get ( ) vlist = [ ] for name in kbos : if not re . search ( re_string , name ) : continue vlist . append ( name ) if type ( kbos [ name ] ) == type ( ephem . EllipticalBody ( ) ) : kbos [ name ] . compute ( w . date . get ( ) ) ra... | Draw the actual plot |
47,966 | def eps ( self ) : import tkFileDialog , tkMessageBox filename = tkFileDialog . asksaveasfilename ( message = "save postscript to file" , filetypes = [ 'eps' , 'ps' ] ) if filename is None : return self . postscript ( file = filename ) | Print the canvas to a postscript file |
47,967 | def relocate ( self ) : name = self . SearchVar . get ( ) if kbos . has_key ( name ) : import orbfit , ephem , math jdate = ephem . julian_date ( w . date . get ( ) ) try : ( ra , dec , a , b , ang ) = orbfit . predict ( kbos [ name ] , jdate , 568 ) except : return ra = math . radians ( ra ) dec = math . radians ( dec... | Move to the postion of self . SearchVar |
47,968 | def create_ellipse ( self , xcen , ycen , a , b , ang , resolution = 40.0 ) : import math e1 = [ ] e2 = [ ] ang = ang - math . radians ( 90 ) for i in range ( 0 , int ( resolution ) + 1 ) : x = ( - 1 * a + 2 * a * float ( i ) / resolution ) y = 1 - ( x / a ) ** 2 if y < 1E-6 : y = 1E-6 y = math . sqrt ( y ) * b ptv = s... | Plot ellipse at x y with size a b and orientation ang |
47,969 | def create_pointing ( self , event ) : import math ( ra , dec ) = self . c2p ( ( self . canvasx ( event . x ) , self . canvasy ( event . y ) ) ) this_camera = camera ( camera = self . camera . get ( ) ) ccds = this_camera . getGeometry ( ra , dec ) items = [ ] for ccd in ccds : ( x1 , y1 ) = self . p2c ( ( ccd [ 0 ] , ... | Plot the sky coverage of pointing at event . x event . y on the canavas |
47,970 | def getGeometry ( self , ra = None , dec = None ) : import math , ephem ccds = [ ] if ra is None : ra = self . ra if dec is None : dec = self . dec self . ra = ephem . hours ( ra ) self . dec = ephem . degrees ( dec ) for geo in self . geometry [ self . camera ] : ycen = math . radians ( geo [ "dec" ] ) + dec xcen = ma... | Return an array of rectangles that represent the ra dec corners of the FOV |
47,971 | def produce_fake_hash ( x ) : h = np . random . binomial ( 1 , 0.5 , ( x . shape [ 0 ] , 1024 ) ) packed = np . packbits ( h , axis = - 1 ) . view ( np . uint64 ) return zounds . ArrayWithUnits ( packed , [ x . dimensions [ 0 ] , zounds . IdentityDimension ( ) ] ) | Produce random binary features totally irrespective of the content of x but in the same shape as x . |
47,972 | def _parse_raw_bytes ( raw_bytes ) : bytes_list = [ int ( x , base = 16 ) for x in raw_bytes . split ( ) ] return bytes_list [ 0 ] , bytes_list [ 1 ] , bytes_list [ 2 : ] | Convert a string of hexadecimal values to decimal values parameters |
47,973 | def _send_raw_command ( ipmicmd , raw_bytes ) : netfn , command , data = _parse_raw_bytes ( raw_bytes ) response = ipmicmd . raw_command ( netfn , command , data = data ) return response | Use IPMI command object to send raw ipmi command to BMC |
47,974 | def get_tpm_status ( d_info ) : ipmicmd = ipmi_command . Command ( bmc = d_info [ 'irmc_address' ] , userid = d_info [ 'irmc_username' ] , password = d_info [ 'irmc_password' ] ) try : response = _send_raw_command ( ipmicmd , GET_TPM_STATUS ) if response [ 'code' ] != 0 : raise IPMIFailure ( "IPMI operation '%(operatio... | Get the TPM support status . |
47,975 | def _pci_seq ( ipmicmd ) : for i in range ( 1 , 0xff + 1 ) : try : res = _send_raw_command ( ipmicmd , GET_PCI % hex ( i ) ) yield i , res except ipmi_exception . IpmiException as e : raise IPMIFailure ( "IPMI operation '%(operation)s' failed: %(error)s" % { 'operation' : "GET PCI device quantity" , 'error' : e } ) | Get output of ipmiraw command and the ordinal numbers . |
47,976 | def get_pci_device ( d_info , pci_device_ids ) : ipmicmd = ipmi_command . Command ( bmc = d_info [ 'irmc_address' ] , userid = d_info [ 'irmc_username' ] , password = d_info [ 'irmc_password' ] ) response = itertools . takewhile ( lambda y : ( y [ 1 ] [ 'code' ] != 0xC9 and y [ 1 ] . get ( 'error' ) is None ) , _pci_se... | Get quantity of PCI devices . |
47,977 | def defaults ( current : dict , * args : AnyMapping ) -> dict : r for data in args : for key , value in data . items ( ) : current . setdefault ( key , value ) return current | r Override current dict with defaults values . |
47,978 | def validate_func_factory ( validator_class : Any ) -> ValidateFunc : def validate_func ( schema : AnyMapping , pure_data : AnyMapping ) -> AnyMapping : return validator_class ( schema ) . validate ( pure_data ) return validate_func | Provide default function for Schema validation . |
47,979 | def moreData ( ra , dec , box ) : import cfhtCutout cdata = { 'ra_deg' : ra , 'dec_deg' : dec , 'radius_deg' : 0.2 } inter = cfhtCutout . find_images ( cdata , 0.2 ) | Search the CFHT archive for more images of this location |
47,980 | def xpacheck ( ) : import os f = os . popen ( 'xpaaccess ds9' ) l = f . readline ( ) f . close ( ) if l . strip ( ) != 'yes' : logger . debug ( "\t Can't get ds9 access, xpaccess said: %s" % ( l . strip ( ) ) ) return ( False ) return ( True ) | Check if xpa is running |
47,981 | def mark ( x , y , label = None ) : if label is not None : os . system ( "xpaset -p ds9 regions color red " ) cmd = "echo 'image; text %d %d # text={%s}' | xpaset ds9 regions " % ( x , y , label ) else : os . system ( "xpaset -p ds9 regions color blue" ) cmd = "echo 'image; circle %d %d 10 ' | xpaset ds9 regions " % ( ... | Mark a circle on the current image |
47,982 | def display ( url ) : import os oscmd = "curl --silent -g --fail --max-time 1800 --user jkavelaars '%s'" % ( url ) logger . debug ( oscmd ) os . system ( oscmd + ' | xpaset ds9 fits' ) return | Display a file in ds9 |
47,983 | def inv ( self ) : self . x , self . y = self . y , self . x self . _x_ , self . _y_ = self . _y_ , self . _x_ self . xfac , self . yfac = 1 / self . yfac , 1 / self . xfac self . _xfac_ , self . _yfac_ = 1 / self . _yfac_ , 1 / self . _xfac_ self . _u = 1 / self . _u . conj ( ) | Invert the transform . |
47,984 | def matrix ( self , full = False , keeppads = True ) : v = np . fft . hfft ( self . _u , n = self . N ) / self . N idx = sum ( np . ogrid [ 0 : self . N , - self . N : 0 ] ) C = v [ idx ] if keeppads : a = self . _yfac_ . copy ( ) b = self . _xfac_ . copy ( ) else : a = self . yfac . copy ( ) b = self . xfac . copy ( )... | Return matrix form of the integral transform . |
47,985 | def _pad ( self , a , axis , extrap , out ) : assert a . shape [ axis ] == self . Nin axis %= a . ndim to_axis = [ 1 ] * a . ndim to_axis [ axis ] = - 1 Npad = self . N - self . Nin if out : _Npad , Npad_ = Npad - Npad // 2 , Npad // 2 else : _Npad , Npad_ = Npad // 2 , Npad - Npad // 2 try : _extrap , extrap_ = extrap... | Add padding to an array . |
47,986 | def _unpad ( self , a , axis , out ) : assert a . shape [ axis ] == self . N Npad = self . N - self . Nin if out : _Npad , Npad_ = Npad - Npad // 2 , Npad // 2 else : _Npad , Npad_ = Npad // 2 , Npad - Npad // 2 return np . take ( a , range ( _Npad , self . N - Npad_ ) , axis = axis ) | Undo padding in an array . |
47,987 | def check ( self , F ) : assert F . ndim == 1 , "checker only supports 1D" f = self . xfac * F fabs = np . abs ( f ) iQ1 , iQ3 = np . searchsorted ( fabs . cumsum ( ) , np . array ( [ 0.25 , 0.75 ] ) * fabs . sum ( ) ) assert 0 != iQ1 != iQ3 != self . Nin , "checker giving up" fabs_l = fabs [ : iQ1 ] . mean ( ) fabs_m ... | Rough sanity checks on the input function . |
47,988 | def fft ( x , axis = - 1 , padding_samples = 0 ) : if padding_samples > 0 : padded = np . concatenate ( [ x , np . zeros ( ( len ( x ) , padding_samples ) , dtype = x . dtype ) ] , axis = axis ) else : padded = x transformed = np . fft . rfft ( padded , axis = axis , norm = 'ortho' ) sr = audio_sample_rate ( int ( Seco... | Apply an FFT along the given dimension and with the specified amount of zero - padding |
47,989 | def set_bias ( self , bias ) : self . x_offset += ( bias - self . _bias ) self . _bias = bias self . _build_cdict ( ) | Adjusts the image bias . |
47,990 | def set_contrast ( self , contrast ) : self . _contrast = contrast self . x_spread = 2 * ( 1.0 - contrast ) self . y_spread = 2.0 - 2 * ( 1.0 - contrast ) self . _build_cdict ( ) | Adjusts the image contrast . |
47,991 | def _copy ( src , dst , src_is_storage , dst_is_storage ) : if src_is_storage and dst_is_storage : system_src = get_instance ( src ) system_dst = get_instance ( dst ) if system_src is system_dst : if system_src . relpath ( src ) == system_dst . relpath ( dst ) : raise same_file_error ( "'%s' and '%s' are the same file"... | Copies file from source to destination |
47,992 | def copy ( src , dst ) : src , src_is_storage = format_and_is_storage ( src ) dst , dst_is_storage = format_and_is_storage ( dst ) if not src_is_storage and not dst_is_storage : return shutil_copy ( src , dst ) with handle_os_exceptions ( ) : if not hasattr ( dst , 'read' ) : try : if isdir ( dst ) : dst = join ( dst ,... | Copies a source file to a destination file or directory . |
47,993 | def copyfile ( src , dst , follow_symlinks = True ) : src , src_is_storage = format_and_is_storage ( src ) dst , dst_is_storage = format_and_is_storage ( dst ) if not src_is_storage and not dst_is_storage : return shutil_copyfile ( src , dst , follow_symlinks = follow_symlinks ) with handle_os_exceptions ( ) : try : if... | Copies a source file to a destination file . |
47,994 | def _handle_client_error ( ) : try : yield except _ClientError as exception : error = exception . response [ 'Error' ] if error [ 'Code' ] in _ERROR_CODES : raise _ERROR_CODES [ error [ 'Code' ] ] ( error [ 'Message' ] ) raise | Handle boto exception and convert to class IO exceptions |
47,995 | def _get_session ( self ) : if self . _session is None : self . _session = _boto3 . session . Session ( ** self . _storage_parameters . get ( 'session' , dict ( ) ) ) return self . _session | S3 Boto3 Session . |
47,996 | def _get_client ( self ) : client_kwargs = self . _storage_parameters . get ( 'client' , dict ( ) ) if self . _unsecure : client_kwargs = client_kwargs . copy ( ) client_kwargs [ 'use_ssl' ] = False return self . _get_session ( ) . client ( "s3" , ** client_kwargs ) | S3 Boto3 client |
47,997 | def _handle_azure_exception ( ) : try : yield except _AzureHttpError as exception : if exception . status_code in _ERROR_CODES : raise _ERROR_CODES [ exception . status_code ] ( str ( exception ) ) raise | Handles Azure exception and convert to class IO exceptions |
47,998 | def _properties_model_to_dict ( properties ) : result = { } for attr in properties . __dict__ : value = getattr ( properties , attr ) if hasattr ( value , '__module__' ) and 'models' in value . __module__ : value = _properties_model_to_dict ( value ) if not ( value is None or ( isinstance ( value , dict ) and not value... | Convert properties model to dict . |
47,999 | def _get_endpoint ( self , sub_domain ) : storage_parameters = self . _storage_parameters or dict ( ) account_name = storage_parameters . get ( 'account_name' ) if not account_name : raise ValueError ( '"account_name" is required for Azure storage' ) suffix = storage_parameters . get ( 'endpoint_suffix' , 'core.windows... | Get endpoint information from storage parameters . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.