def slurp_single_case(filename, case_letter): """ Slurps a single case and initializes each element. Stores each row of data with unique keys in to the database """ if not os.path.isfile(filename): print "Could not find file %s" % (filename, ) raise IOError fnam, fext = os.path.splitext(filename) print '\nReading %s' % filename if 'sav' in fext: if app_settings.USE_CASPY and run_in_python('slurp.py', filename): # test to see if we can use CASPY or it crashes in a subprocess import caspy import psse_utils as utils case = caspy.Savecase(filename) assert case.pssopn[ 'IERR'] is 0, 'Error using caspy to read in %s: Check savecase version!!' % filename utils.fix_caspy_case(case) else: app_settings.USE_CASPY = False print 'Could not use Caspy' check_pssedongle() psspy.case(filename) else: check_pssedongle() app_settings.USE_CASPY = False with open(filename, 'r') as fid: rawheader = fid.readline() pssevers = check_psse_version(rawheader) psspy.readrawversion(0, pssevers, filename) slurp_con = get_slurp_db_con() slurp_con.execute("DELETE FROM slurp%s" % (case_letter, )) for e in elements.values(): param_cnt = slurp_element(e, case_letter, slurp_con) elem_cnt = param_cnt / len(e.writables) if elem_cnt == 1: print 'Read in %s %s element.' % (elem_cnt, e.elem_name) else: print 'Read in %s %s elements.' % (elem_cnt, e.elem_name) slurp_con.commit() slurp_con.close()
def openRaw(self, filepath): ''' Reads and opens a raw file ''' ierr = psspy.readrawversion(0, '33.0', filepath) (folder, file) = os.path.split(filepath) self.caseName = file[:-4] assert ierr == 0, 'Raw file cannot be opened'
def open_raw(self, filepath): ''' Opens a raw file in PSS/E ''' ierr = psspy.readrawversion(0, '33.0', filepath) (_, fname) = os.path.split(filepath) self.case_name = fname[:-4] assert ierr == 0, 'Raw file cannot be opened'
def openRaw(self, filepath): ''' Reads and opens a raw file Runs a power flow for the current raw file ''' ierr = psspy.readrawversion(0, '33.0', filepath) (folder, file) = os.path.split(filepath) self.caseName = file[:-4] psspy.fnsl([1,2,0,0,1,0,0,0]) assert ierr == 0, 'Raw file cannot be opened'
def load_model_raw(self, model_path, logger): """ Funkce pro nacteni modelu site ve formatu RAW. @return: V pripade chyby je potreba proverit API dokumentaci PSS/E """ filename = model_path.split('\\')[-1] with redirected_stdout() as fake_stdout: ierr = psspy.readrawversion(0, """32""", model_path) if ierr == 0: logger.info("Model {} uspesne nacten do PSS/E.".format(filename)) else: logger.error( "Model {} nebyl nacten do PSS/E. PSS/E chyba: {}.".format( filename, ierr)) return