def setexpnd(): if s.schcon.debug: s.wlog(0, "SETEXPND: Starting.") for i in range(s.setn1.nset): s.setstdef(i+1) catalog = SetupCatalog() catalog.read() setup_entries = catalog.scheduled() copy_to = len(setup_entries) for setup_entry in setup_entries: for station in setup_entry.setsta[setup_entry.setsta != ""]: if copy_to >= len(catalog.entries): s.wlog(1, "SETEXPND: There are too many setup groups after " "creating new ones") s.wlog(1, " for each station in the input setups.") s.wlog(1, " Maximum is {} which is setups times " "stations.".format(len(catalog.entries))) s.errlog("SETEXPND: You need fewer setups or a bigger MSET in " "SCHED.") dest = catalog.entries[copy_to] dest.__dict__.update(copy.deepcopy(setup_entry.__dict__)) dest.setsta[0] = station copy_to += 1 if copy_to == len(setup_entries): s.errlog("SETEXPND: None of the specified setups are used.") # move the new entries to the front and invalidate the others catalog.entries = catalog.entries[len(setup_entries):] + \ catalog.entries[:len(setup_entries)] s.setn1.nset = copy_to - len(setup_entries) station_catalog = StationCatalog() station_catalog.read() stations = station_catalog.used() for ks, setup_entry in enumerate(catalog.scheduled(), 1): setup_entry.listks = ks station_index = next(s.schn1.stanum[station.ischsta-1] for station in stations if station.station == setup_entry.setsta[0]) if station_index is None: s.wlog(1, "SETEXPND: Did not get station number. " "Programming problem.") s.wlog(1, " Station: {}".format(setup_entry.setsta[0])) s.errset(ks) setup_entry.isetsta = station_index catalog.write(range(s.setn1.nset)) for lsta in range(s.schn1.nsta): for iscn in range(s.schn1.nscans): s.schn2a.nsetup[iscn, lsta] = s.gnset(iscn+1, lsta+1)
def setbbc(ks, setup_catalog, frequency_entries, station_entries): if s.setn1.sdebug: s.wlog(0, "SETBBC: Starting.") setup_entry = setup_catalog.entries[ks - 1] for ich, channel in enumerate(setup_entry.channel): if channel.ifreqnum >= 1: if channel.ifchan == "": channel.ifchan = frequency_entries[channel.ifreqnum-1].\ fifnam[channel.ifreqif-1] else: if channel.ifchan == "": s.wlog( 1, "SETBBC: Cannot set IFCHANs. First bad channel: " "{} of {} total.".format(ich + 1, len(setup_entry.channel))) s.errset(ks) setup_catalog.write(range(ks - 1, ks)) station_entry = station_entries[setup_entry.isetsta - 1] if (station_entry.recorder == "S2") and \ (station_entry.dar in ("VLBA", "VLBAG", "VLBA4")): s.bbcvs2(ks) else: def handle_func(f): def handle(ks): f(ks, setup_entry, station_entry) setup_catalog.write(range(ks - 1, ks)) return handle bbc_func = { "VLBA": s.bbcvlba, "RDBE": s.bbcrdbe, "RDBE2": s.bbcrdbe, "WIDAR": s.bbcwidar, "VLBAG": s.bbcgeo, "VLBA4": s.bbcgeo, "MKIV": s.bbcm4, "DBBC": handle_func(bbcdbbc), "DBBC3": handle_func(bbcdbbc), "CDAS": s.bbccdas, "R1002": s.bbckvsr, "LBA": s.bbclba, "eMERL": handle_func(bbc_emerlin) }.get(station_entry.dar, None) if bbc_func is not None: bbc_func(ks) elif station_entry.dar != "NONE": s.wlog( 1, "SETBBC: SCHED does not set default BBCs for format: {}, " "DAR type: {}".format(setup_entry.format, station_entry.dar)) s.errset(ks)
def bbc_emerlin(ks, setup_entry, station_entry): """ ks: Fortran index into setups setup_entry: changes will be written to catalog station_entry: read only """ if s.schcon.debug: s.wlog(1, "BBCEMERLIN: Starting") ifbbc, mif = ifdbbc("GEO", False) ifnam = list("AB") max_bbc = ifbbc.shape[0] if station_entry.nbbc > max_bbc: s.wlog( 1, "BBCDBBC: Number of VCs at {} Larger than maximum expected: " "{}".format(setup_entry.setsta[0], max_bbc)) s.wlog(1, " Catalog or programming problem ") s.errset(ks) ubbc = bbcalt(ks, setup_entry, ifbbc, ifnam, "eMERL", "BBCEMERLIN")
def bbcdbbc(ks, setup_entry, station_entry): """ ks: Fortran index into setups setup_entry: changes will be written to catalog station_entry: read only """ if s.schcon.debug: s.wlog(1, "BBCDBBC: Starting") if station_entry.dar == "DBBC3": ifbbc, mif = ifdbbc3() ifnam = list("ABCDEFGH") else: e_firmware = SetupCatalog.is_dbbc_e_firmware(setup_entry) ifbbc, mif = ifdbbc(station_entry.dbbcver, e_firmware) ifnam = list("ABCD") max_bbc = ifbbc.shape[0] if station_entry.nbbc > max_bbc: s.wlog( 1, "BBCDBBC: Number of VCs at {} Larger than maximum expected: " "{}".format(setup_entry.setsta[0], max_bbc)) s.wlog(1, " Catalog or programming problem ") s.errset(ks) ubbc = bbcalt(ks, setup_entry, ifbbc, ifnam, "DBBC", "BBCDBBC")
def chkset(ks): global itout, warn2cm setup_entry = SetupCatalog().read()[ks - 1] station_catalog = StationCatalog() station_catalog.read() station_catalog.read_non_scan_scheduled_attributes() station_entry = station_catalog.entries[setup_entry.isetsta - 1] if s.schcon.debug: s.wlog(0, "CHKSET: Starting on {} in:".format(setup_entry.setsta[0])) s.wlog(0, " {}".format(setup_entry.setname)) errs = False sampwarn = True if s.schn1.notape and (setup_entry.format != "NONE"): obstype = f2str(s.schsco.obstyp) s.wlog( itout, "CHKSET: *** WARNING - OBSTYPE={} but setup has " "FORMAT={}".format(obstype, setup_entry.format)) s.wlog(itout, " No tapes will be recorded with this OBSTYPE.") if obstype == "NONE": s.wlog( itout, " NONE is the default OBSTYPE. " "Did you forget to specify it?") else: s.wlog(itout, " Was this intended?") itout = 0 if not s.schn1.vlaonly: if s.schn1.mark2 and (setup_entry.format != "MARKII"): s.wlog( 1, "CHKSET: For OBSTYP=MKII, FORMAT must be MARKII, not: " "{}".format(setup_entry.format)) errs = True if (s.schcon.dovex or s.schcon.dovsop) and setup_entry.frswitch: s.wlog(1, "CHKSET: Cannot frequency switch with VEX or VSOP file.") if len(setup_entry.channel) < 1: s.wlog( 1, "CHKSET: Setup file must have at least 1 channel unless " "OBSTYPE=VLA.") s.errlog("CHKSET: The error is in {}".format(setup_entry.setname)) overwarn = False for ich, channel in enumerate(setup_entry.channel): if channel.sidebd not in ("U", "L"): s.wlog( 1, "CHKSET: Sideband not U or L in {}".format( setup_entry.setname)) errs = True if channel.pol[:3] not in ("RCP", "LCP", "X", "Y"): s.wlog(1, "CHKSET: In setup {} polarization of chan {} " "not given or deduced (should be RCP, LCP, X or Y).".\ format(setup_entry.setname, ich+1)) errs = True for jch, other in enumerate(setup_entry.channel[ich + 1:], ich + 1): if (channel.pol != other.pol) and \ (channel.ifchan == other.ifchan): s.wlog( 1, "CHKSET: In setup {} IF channel {} is " "assigned to {} in chan {} and to {} in chan {} " "Not possible.".format(setup_entry.setname, channel.ifchan, channel.pol, ich + 1, channel.pol, jch + 1)) errs = True if s.schn1.vlbitp: if channel.bbfilt > 0.5001 * setup_entry.samprate: s.wlog(1, "CHKSET: Bandwidth more than half of sample rate") errs = True if (channel.bbfilt < 0.4999 * setup_entry.samprate) \ and sampwarn: s.wlog(0, "CHKSET note: Oversampling specified.") sampwarn = False if ich > 0: freq_i = freq_range(channel) for jch, other in enumerate(setup_entry.channel[:ich - 1]): if channel.pol == other.pol: freq_j = freq_range(other) if (freq_j[0] <= freq_i[0] < freq_j[1]) or \ (freq_j[0] < freq_i[1] <= freq_j[1]): overwarn = True # end of channel loop if overwarn: s.wlog( 1, "CHKSET: Setup file: {} Has overlapping channels. " "Intended?".format(setup_entry.setname)) if station_entry.dar.startswith("RDBE"): errs = s.chkrdbe(ks, errs) if station_entry.dar.startswith("DBBC"): errs = chkdbbc(ks, setup_entry, station_entry) or errs if station_entry.dar == "eMERL": errs = check_emerlin(setup_entry, station_entry) or errs if station_entry.dar == "WIDAR": errs = s.chkwidar(ks, errs) if station_entry.dar in ("VLBA", "VLBAG", "VLBA4"): errs = s.chkvdar(ks, station_entry.nbbc, errs) if station_entry.dar == "VLBA4": errs = s.chkv4dar(ks, errs) if station_entry.dar == "VLBAG": errs = s.chkgdar(ks, errs) if station_entry.dar == "MKIV": errs = s.chk4dar(ks, station_entry.nbbc, errs) if station_entry.dar == "CDAS": errs = s.chkcdas(ks, errs) if s.schn1.vlbitp: if station_entry.usedisk: errs = s.chkdisk(ks, errs) if station_entry.recorder in ("VLBA", "MKIV", "VLBA4") and \ (setup_entry.format != "NONE"): errs = s.chkspd(ks, errs) if len(np.unique(setup_entry.bits)) > 1: s.wlog( 1, "CHKSET: All channels must use the same number of " "bits.") errs = True # end of if not vlaonly if warn2cm and (15100 < setup_entry.channel[0].freqref < 15500) and \ setup_entry.setsta[0].startswith("VLBA") and (setup_entry.totbps < 1000): s.wlog(1, " ") s.wlog( 1, "CHKSET: See sched.runlog for information on 2cm " "frequencies.") s.wrtmsg(0, "CHKSET", "warn2cm") warn2cm = False if setup_entry.setsta[0].startswith("VLBA"): errs = s.chkvlba(ks, errs) if setup_entry.setsta[0].startswith("VLA"): errs = s.chkvla(ks, errs) if errs: s.wlog(1, "CHKSET: Freq groups used or checked:") frequencies = FrequencyCatalog().read() for ich, channel in enumerate(setup_entry.channel): if channel.ifreqnum > 0: s.wlog( 1, " Channel: {} Frequency Group: {}".format( ich + 1, frequencies[channel.ifreqnum - 1].frname)) s.errset(ks)
def bbcalt(ks, setup_entry, ifbbc, ifnam, warning, caller): if s.schcon.debug: s.wlog(0, "BBCALT starting. Called by {}".format(caller)) max_bbc = ifbbc.shape[0] max_if = ifbbc.shape[1] ubbc = np.full(max_bbc, False) for bbc in setup_entry.bbc: if bbc > 0: ubbc[bbc - 1] = True ifinput = {} for ich, channel in enumerate(setup_entry.channel): if channel.bbc == 0: for other in setup_entry.channel[:ich]: if channel.freqref == other.freqref: if channel.ifchan == other.ifchan: channel.bbc = other.bbc break elif channel.altifc == other.ifchan: channel.bbc = other.bbc channel.ifchan = other.altifc break for ibbc in np.where(np.logical_not(ubbc))[0]: ifs = np.where(ifbbc[ibbc] == 1)[0] for iif in ifs: if channel.bbc != 0: break chknam = ifnam[iif] if (warning == "DBBC") and (iif in ifinput): chknam = ifinput[iif] ifmatch = channel.ifchan.startswith(chknam) altifmatch = channel.altifc.startswith(chknam) if ifmatch or altifmatch: if not ifmatch: channel.ifchan = channel.altifc channel.bbc = ibbc + 1 ubbc[ibbc] = True ifinput[iif] = channel.ifchan if channel.bbc == 0: s.wlog(1, " ") s.wlog(1, "BBCALT: BBC setting problem: ") s.wlog(1, " Setup file: {}".format(setup_entry.setname)) s.wlog(1, " Station: {}".format(setup_entry.setsta[0])) s.wlog(0, " ICHAN={} IFNAME={} ALTIFC={} NNBBC={}".\ format(ich+1, channel.ifchan, channel.altifc, max_bbc)) s.wrtmsg(0, "BBCALT", "noassignbbc") if ich > 4: s.wlog(1, " Maybe too many channels are requested for " "the same IF channel.") if warning in ("GEO1", "GEO2"): s.wlog(0, "Note that 'geodetic' VLBA systems have restrictions " "on IF assignments.") s.wlog(0, " See IFCHAN in the manual.") if warning == "GEO2": s.wlog(0, " They also cannot use 2 bits from more than " "8 BBCs.") elif warning == "S2": s.wlog(0, "Note that the S2 system is not hooked to all BBCs.") s.errset(ks)