コード例 #1
0
    def resolve(self, y0):
        """
        resolve the problem locally on one chunk
        returns local solution and Khi2
        """
        Z = len(self.axeZ)
        N = len(self._axeMframe)
        if FAST:
            dec.AX = self._axeMframe
        scale = y0.max()
        y = y0/scale
        noise, offset = findnoise_offset(y)
# normK=np.sqrt(Z), 
        xrec_PDS, refspec = PDS.pds_vf(self.K1, self.Kt1, Z*N, y-offset, eta=noise*np.sqrt(N), normK=np.sqrt(Z), lamda=self.lamda, nbiter=self.nbiter, ref=None, Khi2=self.computeKhi2, show=False)
        return xrec_PDS.reshape(Z,N)*scale, refspec
コード例 #2
0
def main():
    log = ECC.setup_logging(debug=False)

    (pds, families, members) = PDSChurch.load_families_and_members(
        filename='pdschurch.sqlite3', log=log)

    ministries = PDS.read_table(pds,
                                'MinType_DB',
                                'MinDescRec',
                                columns=['Description'],
                                log=log)

    flipped = dict()
    for key, item in ministries.items():
        flipped[item['Description']] = item

    for key in sorted(flipped):
        print(key)
コード例 #3
0
def _load_members(pds, columns=None, active_only=True, log=None):
    db_num = _get_db_num()

    if not columns:
        columns = list()
    columns.append('Name')
    columns.append('FamRecNum')
    columns.append('DateOfBirth')
    columns.append('MonthOfBirth')
    columns.append('DayOfBirth')
    columns.append('YearOfBirth')
    columns.append('Gender')
    columns.append('MaritalStatusRec')
    columns.append('MemberType')
    columns.append('PictureFile')
    columns.append('Location')
    columns.append('LanguageRec')
    columns.append('EthnicDescRec')
    columns.append('User3DescRec')  # Skills
    columns.append('User4DescRec')  # Occupation
    columns.append('Deceased')
    columns.append('PDSInactive{num}'.format(num=db_num))

    where = ('Mem_DB.CensusMember{db_num}=1'.format(db_num=db_num))
    if active_only:
        where += (' AND '
                  'Mem_DB.deceased=0 AND '
                  '(Mem_DB.PDSInactive{db_num}=0 OR '
                  'Mem_DB.PDSInactive{db_num} is null)'.format(db_num=db_num))

    members = PDS.read_table(pds,
                             'Mem_DB',
                             'MemRecNum',
                             columns=columns,
                             log=log,
                             where=where)

    for m in members.values():
        _normalize_boolean(m, src='Deceased')
        _normalize_boolean(m, src=f'PDSInactive{db_num}', dest="Inactive")
        _normalize_filename(m, src='PictureFile')
        m['date_of_birth'] = _normalize_date(m['DateOfBirth'], sentinel=False)

    return members
コード例 #4
0
    def resolve(self, y0):
        """
        resolve the problem locally on one chunk
        returns local solution and Khi2
        """
        Z1 = len(self.axeZ1)
        N1 = len(self.axeM1)
        Z2 = len(self.axeZ2)
        N2 = len(self.axeM2)
        if FAST:
            dec.AX1 = self.axeM1
            dec.AX2 = self.axeM2
        scale = y0.max()
        y = y0/scale
        self.noise, self.offset = findnoise_offset(y.ravel())
# normK=np.sqrt(Z), 
        xrec_PDS, refspec = PDS.pds_vf(self.K1, self.Kt1, Z1*Z2*N1*N2, y.ravel()-self.offset, eta=self.noisefactor*self.noise*np.sqrt(N1*N2),
            normK=np.sqrt(Z1*Z2), lamda=self.lamda, nbiter=self.nbiter, ref=None, Khi2=self.computeKhi2, show=False)
        return xrec_PDS.reshape(Z1,Z2,N1,N2)*scale, refspec
コード例 #5
0
def _load_families(pds, columns=None, active_only=True, log=None):
    db_num = _get_db_num()

    if not columns:
        columns = list()
    columns.append('Name')
    columns.append('MailingName')
    columns.append('ParKey')
    columns.append('StreetAddress1')
    columns.append('StreetAddress2')
    columns.append('StreetCityRec')
    columns.append('StreetZip')
    columns.append('StatDescRec')
    columns.append('PictureFile')
    columns.append('EnvelopeUser')
    columns.append('Visitor')
    columns.append('SendNoMail')
    columns.append('PDSInactive{num}'.format(num=db_num))

    where = ('Fam_DB.CensusFamily{db_num}=1'.format(db_num=db_num))
    if active_only:
        where += (' AND '
                  '(Fam_DB.PDSInactive{db_num}=0 OR '
                  'FAM_DB.PDSInactive{db_num} is null)'.format(db_num=db_num))

    families = PDS.read_table(pds,
                              'Fam_DB',
                              'FamRecNum',
                              columns=columns,
                              log=log,
                              where=where)

    for f in families.values():
        _normalize_boolean(f, src=f'PDSInactive{db_num}', dest="Inactive")
        _normalize_boolean(f, src='SendNoMail')
        _normalize_boolean(f, src='EnvelopeUser')
        _normalize_filename(f, src='PictureFile')

    return families
コード例 #6
0
ファイル: PDSChurch.py プロジェクト: fragalcer/epiphany
def load_families_and_members(filename=None,
                              pds=None,
                              active_only=True,
                              parishioners_only=True,
                              log=None):

    if pds and filename:
        raise Exception(
            "Cannot supply both filename *and* PDS SQLite3 cursor -- only supply one or the other"
        )

    if filename:
        pds = PDS.connect(filename)

    city_states = PDS.read_table(pds,
                                 'City_DB',
                                 'CityRec',
                                 columns=['CityState'],
                                 log=log)
    statuses = PDS.read_table(pds,
                              'StatusType_DB',
                              'StatusDescRec',
                              columns=['Description', 'Active'],
                              log=log)
    ministries = PDS.read_table(pds,
                                'MinType_DB',
                                'MinDescRec',
                                columns=['Description'],
                                log=log)
    talents = PDS.read_table(pds,
                             'TalType_DB',
                             'TalDescRec',
                             columns=['Description'],
                             log=log)
    birth_places = PDS.read_table(pds,
                                  'Ask_DB',
                                  'AskRecNum',
                                  columns=['AskMemNum', 'BirthPlace'],
                                  log=log)
    date_places = PDS.read_table(pds,
                                 'DatePlace_DB',
                                 'DatePlaceRecNum',
                                 log=log)
    date_types = PDS.read_table(pds,
                                'DateType_DB',
                                'DescRec',
                                columns=['Description'],
                                log=log)
    phone_types = PDS.read_table(pds,
                                 'PhoneTyp_DB',
                                 'PhoneTypeRec',
                                 columns=['Description'],
                                 log=log)
    req_types = PDS.read_table(pds,
                               'ReqType_DB',
                               'ReqDescRec',
                               columns=['Description', 'Expires'],
                               log=log)
    emails = PDS.read_table(
        pds,
        'MemEMail_DB',
        'EMailRec',
        columns=['MemRecNum', 'EMailAddress', 'EMailOverMail', 'FamEmail'],
        log=log)
    languages = PDS.read_table(pds,
                               'LangType_DB',
                               'LanguageRec',
                               columns=['Description'],
                               log=log)
    mem_phones = PDS.read_table(
        pds,
        'MemPhone_DB',
        'PhoneRec',
        columns=['Rec', 'Number', 'PhoneTypeRec', 'Unlisted'],
        log=log)
    mem_keyword_types = PDS.read_table(pds,
                                       'MemKWType_DB',
                                       'DescRec',
                                       columns=['Description'],
                                       log=log)
    mem_keywords = PDS.read_table(pds,
                                  'MemKW_DB',
                                  'MemKWRecNum',
                                  columns=['MemRecNum', 'DescRec'],
                                  log=log)
    mem_ministries = PDS.read_table(
        pds,
        'MemMin_DB',
        'MemKWRecNum',
        columns=['MinDescRec', 'MemRecNum', 'StatusDescRec'],
        log=log)
    mem_talents = PDS.read_table(
        pds,
        'MemTal_DB',
        'MemKWRecNum',
        columns=['TalDescRec', 'MemRecNum', 'StatusDescRec'],
        log=log)
    mem_dates = PDS.read_table(pds,
                               'MemDates_DB',
                               'MemDateRecNum',
                               columns=['MemRecNum', 'Date', 'DescRec'],
                               log=log)
    mem_ethnics = PDS.read_table(pds,
                                 'EthType_DB',
                                 'EthnicDescRec',
                                 columns=['Description'],
                                 log=log)
    mem_3kw = PDS.read_table(pds,
                             'User3KW_DB',
                             'User3DescRec',
                             columns=['Description'],
                             log=log)
    mem_4kw = PDS.read_table(pds,
                             'User4KW_DB',
                             'User4DescRec',
                             columns=['Description'],
                             log=log)
    mem_reqs = PDS.read_table(pds,
                              'MemReq_DB',
                              'MemReqRecNum',
                              columns=[
                                  'MemRecNum', 'ReqDescRec', 'ReqDate',
                                  'ReqResult', 'ReqNote', 'ExpirationDate'
                              ])

    relationship_types = PDS.read_table(pds,
                                        'RelType_DB',
                                        'RelDescRec',
                                        columns=['Description'],
                                        log=log)
    marital_statuses = PDS.read_table(pds,
                                      'MemStatType_DB',
                                      'MaritalStatusRec',
                                      columns=['Description'],
                                      log=log)

    fam_keyword_types = PDS.read_table(pds,
                                       'FamKWType_DB',
                                       'DescRec',
                                       columns=['Description'],
                                       log=log)
    fam_keywords = PDS.read_table(pds,
                                  'FamKW_DB',
                                  'FamKWRecNum',
                                  columns=['FamRecNum', 'DescRec'],
                                  log=log)
    fam_status_types = PDS.read_table(pds,
                                      'FamStatType_DB',
                                      'StatDescRec',
                                      columns=['Description'],
                                      log=log)
    fam_phones = PDS.read_table(
        pds,
        'FamPhone_DB',
        'PhoneRec',
        columns=['Rec', 'Number', 'PhoneTypeRec', 'Unlisted'],
        log=log)

    # Descriptions of each fund
    funds = PDS.read_table(pds,
                           'FundSetup_DB',
                           'SetupRecNum',
                           columns=['FundNumber', 'FundKey', 'FundName'],
                           log=log)
    # Each fund also has one or more time periods associated with it
    fund_periods = PDS.read_table(pds,
                                  'FundPeriod_DB',
                                  'FundPeriodRecNum',
                                  columns=[
                                      'SetupRecNum', 'FundNumber', 'FundYear',
                                      'FundStart', 'FundEnd'
                                  ],
                                  log=log)
    # When a Family contributes, each contribution is assocaited with
    # a "funding activity"
    fund_activities = PDS.read_table(pds,
                                     'FundAct_DB',
                                     'ActRecNum',
                                     columns=[
                                         'FundRecNum', 'GroupName', 'Activity',
                                         'Function', 'GroupOrder', 'pdsorder'
                                     ],
                                     log=log)

    # Families' activities with relation to the established funds (there is one
    # entry for each family for each fund to which that family has contributed).
    fam_funds = PDS.read_table(pds,
                               'FamFund_DB',
                               'FDRecNum',
                               columns=[
                                   'FDFamRec', 'FDYear', 'FDFund', 'FDOrder',
                                   'MemRecNum', 'Comment'
                               ],
                               log=log)
    # Pledging information from the family
    fam_fund_rates = PDS.read_table(pds,
                                    'FamFundRate_DB',
                                    'RateRecNum',
                                    columns=[
                                        'FundRecNum', 'FDStartDate',
                                        'FDEndDate', 'FDRate', 'FDRateAdj',
                                        'FDNumber', 'FDPeriod', 'FDTotal',
                                        'Batch', 'BatchDate'
                                    ])
    # A listing of each individual contribution from each family,
    # cross-referenced to fam_funds.
    fam_fund_history = PDS.read_table(pds,
                                      'FamFundHist_DB',
                                      'FERecNum',
                                      columns=[
                                          'FEDate', 'ActRecNum', 'FEFundRec',
                                          'FEFamRec', 'FEAmt', 'FEBatch',
                                          'MemRecNum', 'FEChk', 'FEComment'
                                      ],
                                      log=log)

    member_types = _find_member_types()
    mdtid = _find_member_marriage_date_type(date_types)

    _make_emails_lower_case(emails)

    families = _load_families(pds=pds, active_only=active_only, log=log)
    members = _load_members(pds=pds, active_only=active_only, log=log)

    _link_families_members(families, members)

    if parishioners_only:
        _delete_non_parishioners(families, members)

    _link_family_emails(families, emails)
    _link_family_city_states(families, city_states)
    _link_family_statuses(families, fam_status_types)
    _link_family_phones(families, fam_phones, phone_types)
    _link_family_keywords(families, fam_keyword_types, fam_keywords)

    _parse_member_names(members)
    _link_member_types(members, member_types)
    _link_member_emails(members, emails)
    _link_member_phones(members, mem_phones, phone_types)
    _link_member_keywords(members, mem_keyword_types, mem_keywords)
    _link_member_birth_places(members, birth_places)
    _link_member_ministries(members, ministries, mem_ministries, statuses)
    _link_member_talents(members, talents, mem_talents, statuses)
    _link_member_marriage_dates(members, mem_dates, mdtid)
    _link_member_requirements(members, mem_reqs, req_types)

    _link_member_id(members, 'MaritalStatusRec', 'marital_status',
                    marital_statuses)
    _link_member_id(members, 'LanguageRec', 'language', languages)
    _link_member_id(members, 'EthnicDescRec', 'ethnic', mem_ethnics)
    _link_member_id(members, 'User3DescRec', 'skills', mem_3kw)
    _link_member_id(members, 'User4DescRec', 'occupation', mem_4kw)

    _link_family_funds(funds, fund_periods, fund_activities, families,
                       fam_funds, fam_fund_rates, fam_fund_history, log)

    # Compute family HoH+Spouse salutations
    _compute_family_hoh_and_spouse_salutations(families, log)

    return pds, families, members
コード例 #7
0
ファイル: testPDS.py プロジェクト: colbyZ/GraduationProject
    plt.plot(x, y, 'b', label='样本' + str(j) + '(Slaver)')
plt.legend(prop=zhfont1)

plt.xlabel("波长 (nm)", fontproperties=zhfont1)
plt.ylabel("吸光度 (AU)", fontproperties=zhfont1)
plt.title("两台仪器3组玉米样本光谱对比", fontproperties=zhfont1)
plt.show()

#import numpy as np
import PDS
import Shenks

# 取前 3 组样本
Rms = m5nbsArray[0:3, :]
Rss = mp5nbsArray[0:3, :]
pds = PDS.PDS(Rms, Rss)
# 窗口大小选择
win = 1
k = 1
pds.model(win, k)

Rssun = mp5nbsArray[0:3, :]
Rmsun = m5nbsArray[0:3, :][:, win:Rssun.shape[1] - win]

Rssyuce = pds.predict(Rssun)
# 舍弃窗口两端
xwin = x[win:Rssun.shape[1] - win]
#y1 = averSpec(Rmsyuce) # 预测值
#plt.plot(xwin, y1,'r')
#    y = Rmsun[j, :] - 0.5 * j   #真实值
#    plt.plot(xwin, y, 'b')