示例#1
0
def parseImageParameters(request, session):

    methods = ['site', 'dataset', 'instrument']
    for m in methods:
        if m not in request.params:
            continue
        method = m
        session['method'] = method
        try:
            session[method] = int(request.params.getone(method))
            session['methodkey'] = int(request.params.getone(method))
        except:
            session[method] = request.params.getone(method)
            session['methodkey'] = request.params.getone(method)
        break
    starttime = datetime(int(request.params.getone('byr')),
                         int(request.params.getone('bmo')),
                         int(request.params.getone('bdy')),
                         int(request.params.getone('bhr')),
                         int(request.params.getone('bmn')), 0)
    endtime = datetime(int(request.params.getone('eyr')),
                       int(request.params.getone('emo')),
                       int(request.params.getone('edy')),
                       int(request.params.getone('ehr')),
                       int(request.params.getone('emn')), 0)
    session['altmin'] = float(request.params.getone('lheight')) * 1000
    session['altmax'] = float(request.params.getone('height')) * 1000
    session['starttime'] = starttime.strftime(picnicsession.json_dateformat)
    session['endtime'] = endtime.strftime(picnicsession.json_dateformat)
    #contstruct dpl
    datinfo = lib(**{method: session[method]})
    instruments = datinfo['Instruments']
    name = datinfo['Name']
    datasetname = instruments[0].lower()
    #print figstocapture
    datasets = []
    for inst in instruments:
        datasets.extend(lib.instrument(inst)['datasets'])

    #dplc=dpl_rti(datasetname,starttime,endtime,timedelta(seconds=timeres),endtime-starttime,altmin,altmax,altres);#alt in m
    #construct image generation parameters
    session['dataset'] = datasetname
    session['name'] = name

    if 'custom_processing' in request.params and request.params.getone(
            'custom_processing') != 'default':
        cust = request.params.getone('custom_processing')
        if cust == 'custom':
            try:
                pd = request.params.getone('process_parameters_content')
                pdc = pd.file.read()
                d = json.loads(pdc)  #.file.read())
            except:
                traceback.format_exc()
                return HTTPBadRequest()
        else:
            d = server_archive.get_archived_json(
                request.params.getone('custom_processing_token'), cust)
        #print 'Storing custom process parameters ',request.params.getone('process_parameters_content')
        picnicsession.storejson(session, d, 'process_parameters.json')
    #return HTTPTemporaryRedirect(location=request.route_path('progress_withid',session=sessionid))
    if 'custom_display' in request.params and request.params.getone(
            'custom_display') != 'default':
        cust = request.params.getone('custom_display')
        if cust == 'custom':
            pd = request.params.getone('display_defaults_content')
            print 'Storing custom image parameters to', session[
                'sessionid'], 'display_parameters.json'
            try:
                d = json.loads(pd.file.read())
            except:
                traceback.format_exc()
                return HTTPBadRequest()
        else:
            d = server_archive.get_archived_json(
                request.params.getone('custom_display_token'), cust)
        picnicsession.storejson(session, d, 'display_parameters.json')
        session['figstocapture'] = None
        getdatasets = datasets
        imagesetlist = jsgen.formsetsForInstruments(datasets, 'images')
        session['figrequest'] = {}
        for i in imagesetlist:
            session['figrequest'][i['formname']] = 'custom'
    elif 'display_defaults_file' in request.params:
        session['display_defaults_file'] = request.params.getone(
            'display_defaults_file')
        if os.path.sep in session['display_defaults_file']:
            session['display_defaults_file'] = picnicsession.sessionfile(
                session, session['display_defaults_file'])
        session['figstocapture'] = None
        getdatasets = datasets
        imagesetlist = jsgen.formsetsForInstruments(datasets, 'images')
        session['figrequest'] = {}
        for i in imagesetlist:
            session['figrequest'][i['formname']] = 'custom'
    else:
        session['display_defaults_file'] = 'all_plots.json'
        imagesetlist = jsgen.formsetsForInstruments(datasets, 'images')
        getdatasets = []
        figstocapture = {}
        session['figrequest'] = {}
        for i in imagesetlist:
            #print i
            try:
                setmode = request.params.getone(i['formname'])
                session['figrequest'][i['formname']] = setmode
                figstocapture[i['setenum']] = i['sets'][setmode]['figs']
                if len(i['sets'][setmode]['figs']) > 0:  #radio buttons
                    if 'enabled' in i['sets'][setmode]:
                        for dat in i['sets'][setmode]['enabled']:
                            if dat not in getdatasets:
                                getdatasets.append(dat)
                    if 'required' in i['sets'][setmode]:
                        for dat in i['sets'][setmode]['required']:
                            if dat not in getdatasets:
                                getdatasets.append(dat)
                if "options" in i and len(
                        i["options"]
                ) > 0:  #checkboxes only currently, may extend to choicebox
                    for opt in i["options"]:
                        if opt["formname"] in request.params and request.params.getone(
                                opt['formname']):
                            if 'enabled' in opt:
                                for dat in opt['enabled']:
                                    if dat not in getdatasets:
                                        getdatasets.append(dat)
                            if 'required' in opt:
                                for dat in opt['required']:
                                    if dat not in getdatasets:
                                        getdatasets.append(dat)
                            figstocapture[i['setenum']].extend(opt['included'])
                        else:
                            for f in opt['included']:
                                figstocapture[i['setenum']].append('-' + f)
            except:
                pass
        session['figstocapture'] = figstocapture
    session['datastreams'] = getdatasets
    #if None in session['figstocapture']:
    picnicsession.storesession(session)
示例#2
0
def parseNetCDFParameters(request, session):
    session['timeres'] = float(request.params.getone('timeres'))
    session['altres'] = float(request.params.getone('altres'))
    session['maxtimeslice_timedelta'] = 60 * 60 * 2
    session['data_request'] = "images housekeeping"
    session['template'] = request.params.getone('cdltemplatename')
    if session['template'] == 'custom':
        fn = picnicsession.sessionfile(session, 'template.cdl', create=True)
        file(fn, 'w').write(
            request.params.getone('cdltemplate_content').file.read())
        session['template'] = fn
    stf = datetime.strptime(
        session['starttime'],
        picnicsession.json_dateformat).strftime('_%Y%m%dT%H%M')
    etf = datetime.strptime(
        session['endtime'],
        picnicsession.json_dateformat).strftime('_%Y%m%dT%H%M')
    session['filesuffix'] = ('_%gs_%gm' %
                             (session['timeres'], session['altres']))
    session['filemode'] = request.params.getone('filemode')
    session['fileprefix'] = session['dataset'] + '_' + session['filemode']
    session['filename'] = session['dataset'] + stf + etf + session[
        'filesuffix'] + '.nc'
    session['username'] = request.params.getone('username')

    datinfo = lib(**{session['method']: session[session['method']]})
    instruments = datinfo['Instruments']
    #print figstocapture
    datasets = []
    for inst in instruments:
        datasets.extend(lib.instrument(inst)['datasets'])

    fieldstocapture = []
    if not 'allfields' in request.params or not request.params.getone(
            'allfields'):
        fieldsetlist = jsgen.formsetsForInstruments(datasets, 'netcdf')
        getdatasets = []
        for inst in fieldsetlist:  #per instrument
            for subset in inst['sets']:
                subsetincluded = False
                for checkbox in subset['options']:
                    formname = checkbox['formname']
                    if formname not in request.params or not request.params.getone(
                            formname):
                        continue
                    subsetincluded = True
                    for fieldname in checkbox['included']:
                        if fieldname not in fieldstocapture:
                            fieldstocapture.append(fieldname)
                    if 'enabled' in checkbox:
                        for dat in checkbox['enabled']:
                            if dat not in getdatasets:
                                getdatasets.append(dat)
                    if 'required' in checkbox:
                        for dat in checkbox['required']:
                            if dat not in getdatasets:
                                getdatasets.append(dat)
                if subsetincluded:
                    if 'included' in subset:
                        for fieldname in subset['included']:
                            if fieldname not in fieldstocapture:
                                fieldstocapture.append(fieldname)
                    if 'enabled' in subset:
                        for dat in subset['enabled']:
                            if dat not in getdatasets:
                                getdatasets.append(dat)
                    if 'required' in subset:
                        for dat in subset['required']:
                            if dat not in getdatasets:
                                getdatasets.append(dat)
    else:
        getdatasets = datasets
    session['datastreams'] = getdatasets

    print fieldstocapture
    session['selected_fields'] = fieldstocapture

    figstocapture = {}

    if 'custom_display' not in request.params or request.params.getone(
            'custom_display') == 'default':
        imagesetlist = jsgen.formsetsForInstruments(datasets, 'images')
        session['display_defaults_file'] = 'all_plots.json'

        for i in imagesetlist:
            #print i
            try:
                defmode = i['default']
                figstocapture[i['setenum']] = []
                for figname in i['sets'][defmode][
                        'figs']:  #get default images of default set
                    if 'image' in figname and figname not in figstocapture[
                            i['setenum']]:
                        figstocapture[i['setenum']].append(figname)
                if 'options' in i:  #and default options
                    for opt in i['options']:
                        if opt['default']:  #checkbox default is true
                            for figname in i['included']:
                                if 'image' in figname and figname not in figstocapture[
                                        i['setenum']]:
                                    figstocapture[i['setenum']].append(figname)
            except:
                pass
    else:
        figstocapture = None
    session['figstocapture'] = figstocapture
    session['lib_filetype'] = None
    picnicsession.storesession(session)
示例#3
0
def form_view(request):
    #print 'URLREQ: ',request.matched_route.name
    methodtype = request.matchdict['accesstype']
    methodkey = request.matchdict['access']
    try:
        mylib = HSRLImageArchiveLibrarian(**{methodtype: methodkey})
    except RuntimeError:
        return HTTPNotFound(methodtype + "-" + methodkey + " is invalid")
#        return HTTPTemporaryRedirect(location=request.route_path("home"))
    st = mylib()
    instruments = st['Instruments']
    instcount = len(instruments)
    name = st['Name']
    datasets = []
    for inst in instruments:
        datasets.extend(lib.instrument(inst)['datasets'])

    try:
        starttime = validdate(int(request.params.getone('byr')),
                              int(request.params.getone('bmo')),
                              int(request.params.getone('bdy')),
                              int(request.params.getone('bhr')),
                              int(request.params.getone('bmn')))
        endtime = validdate(int(request.params.getone('eyr')),
                            int(request.params.getone('emo')),
                            int(request.params.getone('edy')),
                            int(request.params.getone('ehr')),
                            int(request.params.getone('emn')))
        maxalt = float(request.params.getone('maxalt'))
        minalt = float(request.params.getone('minalt'))
    except:
        #print 'fallback'
        #print request.POST
        #print request.GET
        minalt = 0
        maxalt = 15
        lasttime = mylib.validClosestTime(datetime.utcnow())
        endtime = validdate(lasttime.year, lasttime.month, lasttime.day,
                            lasttime.hour,
                            lasttime.minute - (lasttime.minute % 5))
        starttime = validdate(endtime.year, endtime.month, endtime.day,
                              endtime.hour - 2, endtime.minute)

    oldformparmsdict = {
        methodtype: methodkey,
        'forcematlab': 'yes',
        'byr': '%i' % starttime.year,
        'bmo': '%i' % starttime.month,
        'bdy': '%i' % starttime.day,
        'bhr': '%i' % starttime.hour,
        'bmn': '%i' % starttime.minute,
        'eyr': '%i' % endtime.year,
        'emo': '%i' % endtime.month,
        'edy': '%i' % endtime.day,
        'ehr': '%i' % endtime.hour,
        'emn': '%i' % endtime.minute,
        'minalt': '%i' % minalt,
        'maxalt': '%i' % maxalt
    }
    oldformparams = '&'.join(
        (k + '=' + oldformparmsdict[k]) for k in oldformparmsdict.keys())
    #print oldformparams

    if request.matched_route.name == 'netcdfgen':
        oldurl = "http://lidar.ssec.wisc.edu/cgi-bin/processeddata/retrievedata.cgi?%s" % (
            oldformparams)
    if request.matched_route.name == 'imagegen':
        oldurl = "http://lidar.ssec.wisc.edu/cgi-bin/ahsrldisplay/requestfigs.cgi?%s" % (
            oldformparams)
    if False:  #instcount>3 :#more than just HSRL. python doesn't support it yet
        return HTTPTemporaryRedirect(location=oldurl)

    #print request
    # used in both forms, but simplifies template
    alts = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 20, 25,
            30]  #in kilometers
    # these are only used in netcdf, and not form-configurable. this simplifies the template
    altres = 30
    timeres = 30
    altresvals = [
        7.5, 15, 30, 45, 60, 75, 90, 120, 150, 300, 450, 600, 900, 1200
    ]  # in meters
    timeresvals = [
        2.5, 5, 10, 15, 30, 60, 120, 180, 240, 300, 600, 900, 1200, 3600, 43200
    ]  # in seconds

    #print instruments

    hosttouse = None
    porttouse = None
    if "X-Forwarded-Host" in request.headers:
        hosttouse = request.headers['X-Forwarded-Host']
        porttouse = ''

    return {
        'project':
        'Picnic',
        'bdate':
        starttime,
        'edate':
        endtime,
        'calendar':
        calendar,
        'timedelta':
        timedelta,
        'datetime':
        datetime,
        'altrange': [minalt, maxalt],
        'alts':
        alts,
        'timeresvals':
        timeresvals,
        'altresvals':
        altresvals,
        'timeres':
        timeres,
        'altres':
        altres,
        'imagesets':
        jsgen.formsetsForInstruments(datasets, 'images'),
        'netcdfsets':
        jsgen.formsetsForInstruments(datasets, 'netcdf'),
        'datasets':
        datasets,
        'method':
        methodtype,
        methodtype:
        methodkey,
        'oldurl':
        oldurl,
        'netcdfdestinationurl':
        request.route_url('netcdfreq', _host=hosttouse, _port=porttouse),
        'imagedestinationurl':
        request.route_url('imagereq', _host=hosttouse, _port=porttouse),
        'cdltemplates': {
            "hsrl_nomenclature.cdl": "UW HSRL(NetCDF4)",
            "hsrl_cfradial.cdl": "NCAR CFRadial",
            "hsrl3_processed.cdl": "UW Processed (NetCDF3)",
            "hsrl3_raw.cdl": "UW Raw (NetCDF3)",
            "custom": "User Provided:"
        },
        'cdltemplateorder': [
            "hsrl_nomenclature.cdl", "hsrl_cfradial.cdl",
            "hsrl3_processed.cdl", "hsrl3_raw.cdl", "custom"
        ],
        'userTracking':
        picnicsession.haveUserTracking(),
        #'usercheckurl':request.route_path('userCheck'),#'http://lidar.ssec.wisc.edu/cgi-bin/util/userCheck.cgi',
        'dataAvailabilityURL':
        request.route_path('dataAvailability'),
        'sitename':
        name,
        'setCount':
        setCount,
        'setGen':
        setGen,
        'make_archived_widget':
        server_archive.make_archived_widget,
        'archived_widget_head':
        server_archive.archived_widget_head
    }
示例#4
0
def parseImageParameters(request,session):

    methods=['site','dataset','instrument']
    for m in methods:
        if m not in request.params:
            continue
        method=m
        session['method']=method
        try:
            session[method]=int(request.params.getone(method));
            session['methodkey']=int(request.params.getone(method));
        except:
            session[method]=request.params.getone(method);
            session['methodkey']=request.params.getone(method);
        break
    starttime=datetime(int(request.params.getone('byr')),
                       int(request.params.getone('bmo')),
                       int(request.params.getone('bdy')),
                       int(request.params.getone('bhr')),
                       int(request.params.getone('bmn')),
                       0)
    endtime=datetime(int(request.params.getone('eyr')),
                     int(request.params.getone('emo')),
                     int(request.params.getone('edy')),
                     int(request.params.getone('ehr')),
                     int(request.params.getone('emn')),
                     0)
    session['altmin']=float(request.params.getone('lheight'))*1000
    session['altmax']=float(request.params.getone('height'))*1000
    session['starttime']=starttime.strftime(picnicsession.json_dateformat)
    session['endtime']=endtime.strftime(picnicsession.json_dateformat)
    #contstruct dpl
    datinfo=lib(**{method:session[method]})
    instruments=datinfo['Instruments']
    name=datinfo['Name']
    datasetname=instruments[0].lower()
    #print figstocapture
    datasets=[]
    for inst in instruments:
        datasets.extend(lib.instrument(inst)['datasets'])

    #dplc=dpl_rti(datasetname,starttime,endtime,timedelta(seconds=timeres),endtime-starttime,altmin,altmax,altres);#alt in m
    #construct image generation parameters
    session['dataset']=datasetname
    session['name']=name

    if 'custom_processing' in request.params and request.params.getone('custom_processing')!='default':
        cust=request.params.getone('custom_processing')
        if cust=='custom':
            try:
                pd=request.params.getone('process_parameters_content')
                pdc=pd.file.read()
                d=json.loads(pdc)#.file.read())
            except:
                traceback.format_exc()
                return HTTPBadRequest()
        else:
            d=server_archive.get_archived_json(request.params.getone('custom_processing_token'),cust)
        #print 'Storing custom process parameters ',request.params.getone('process_parameters_content')
        picnicsession.storejson(session,d,'process_parameters.json')
    #return HTTPTemporaryRedirect(location=request.route_path('progress_withid',session=sessionid))
    if 'custom_display' in request.params and request.params.getone('custom_display')!='default':
        cust=request.params.getone('custom_display')
        if cust=='custom':
            pd=request.params.getone('display_defaults_content')
            print 'Storing custom image parameters to',session['sessionid'],'display_parameters.json'
            try:
                d=json.loads(pd.file.read())
            except:
                traceback.format_exc()
                return HTTPBadRequest()
        else:
            d=server_archive.get_archived_json(request.params.getone('custom_display_token'),cust)
        picnicsession.storejson(session,d,'display_parameters.json')
        session['figstocapture']=None
        getdatasets=datasets
        imagesetlist=jsgen.formsetsForInstruments(datasets,'images')
        session['figrequest']={}
        for i in imagesetlist:
            session['figrequest'][i['formname']]='custom'
    elif 'display_defaults_file' in request.params:
        session['display_defaults_file']=request.params.getone('display_defaults_file')
        if os.path.sep in session['display_defaults_file']:
            session['display_defaults_file']=picnicsession.sessionfile(session,session['display_defaults_file'])
        session['figstocapture']=None
        getdatasets=datasets
        imagesetlist=jsgen.formsetsForInstruments(datasets,'images')
        session['figrequest']={}
        for i in imagesetlist:
            session['figrequest'][i['formname']]='custom'
    else:
        session['display_defaults_file']='all_plots.json'
        imagesetlist=jsgen.formsetsForInstruments(datasets,'images')
        getdatasets=[]
        figstocapture={}
        session['figrequest']={}
        for i in imagesetlist:
            #print i
            try:
                setmode=request.params.getone(i['formname'])
                session['figrequest'][i['formname']]=setmode
                figstocapture[i['setenum']]=i['sets'][setmode]['figs']
                if len(i['sets'][setmode]['figs'])>0:#radio buttons
                    if 'enabled' in i['sets'][setmode]:
                        for dat in i['sets'][setmode]['enabled']:
                            if dat not in getdatasets:
                                getdatasets.append(dat)
                    if 'required' in i['sets'][setmode]:
                        for dat in i['sets'][setmode]['required']:
                            if dat not in getdatasets:
                                getdatasets.append(dat)
                if "options" in i and len(i["options"])>0:#checkboxes only currently, may extend to choicebox
                    for opt in i["options"]:
                        if opt["formname"] in request.params and request.params.getone(opt['formname']):
                                if 'enabled' in opt:
                                    for dat in opt['enabled']:
                                        if dat not in getdatasets:
                                            getdatasets.append(dat)
                                if 'required' in opt:
                                    for dat in opt['required']:
                                        if dat not in getdatasets:
                                            getdatasets.append(dat)
                                figstocapture[i['setenum']].extend(opt['included'])
                        else:
                            for f in opt['included']:
                                figstocapture[i['setenum']].append('-'+f)
            except:
                pass
        session['figstocapture']=figstocapture
    session['datastreams']=getdatasets
        #if None in session['figstocapture']:
    picnicsession.storesession(session)
示例#5
0
def parseNetCDFParameters(request,session):
    session['timeres']=float(request.params.getone('timeres'))
    session['altres']=float(request.params.getone('altres'))
    session['maxtimeslice_timedelta']=60*60*2
    session['data_request']="images housekeeping"
    session['template']=request.params.getone('cdltemplatename')
    if session['template']=='custom':
        fn=picnicsession.sessionfile(session,'template.cdl',create=True)
        file(fn,'w').write(request.params.getone('cdltemplate_content').file.read())
        session['template']=fn
    stf=datetime.strptime(session['starttime'],picnicsession.json_dateformat).strftime('_%Y%m%dT%H%M')
    etf=datetime.strptime(session['endtime'],picnicsession.json_dateformat).strftime('_%Y%m%dT%H%M')
    session['filesuffix']=('_%gs_%gm' % (session['timeres'],session['altres']))
    session['filemode']=request.params.getone('filemode')
    session['fileprefix']=session['dataset']+ '_' + session['filemode']
    session['filename']=session['dataset'] + stf + etf + session['filesuffix'] + '.nc'
    session['username']=request.params.getone('username')

    datinfo=lib(**{session['method']:session[session['method']]})
    instruments=datinfo['Instruments']
    #print figstocapture
    datasets=[]
    for inst in instruments:
        datasets.extend(lib.instrument(inst)['datasets'])
 
    fieldstocapture=[]
    if not 'allfields' in request.params or not request.params.getone('allfields'):
        fieldsetlist=jsgen.formsetsForInstruments(datasets,'netcdf')
        getdatasets=[]
        for inst in fieldsetlist:#per instrument
            for subset in inst['sets']:
                subsetincluded=False
                for checkbox in subset['options']:
                    formname=checkbox['formname']
                    if formname not in request.params or not request.params.getone(formname):
                        continue
                    subsetincluded=True
                    for fieldname in checkbox['included']:
                        if fieldname not in fieldstocapture:
                            fieldstocapture.append(fieldname)
                    if 'enabled' in checkbox:
                        for dat in checkbox['enabled']:
                            if dat not in getdatasets:
                                getdatasets.append(dat)
                    if 'required' in checkbox:
                        for dat in checkbox['required']:
                            if dat not in getdatasets:
                                getdatasets.append(dat)
                if subsetincluded:
                    if 'included' in subset:
                        for fieldname in subset['included']:
                            if fieldname not in fieldstocapture:
                                fieldstocapture.append(fieldname)
                    if 'enabled' in subset:
                        for dat in subset['enabled']:
                            if dat not in getdatasets:
                                getdatasets.append(dat)
                    if 'required' in subset:
                        for dat in subset['required']:
                            if dat not in getdatasets:
                                getdatasets.append(dat)
    else:
        getdatasets=datasets
    session['datastreams']=getdatasets

    print fieldstocapture
    session['selected_fields']=fieldstocapture

    figstocapture={}

    if 'custom_display' not in request.params or request.params.getone('custom_display')=='default':
        imagesetlist=jsgen.formsetsForInstruments(datasets,'images')
        session['display_defaults_file']='all_plots.json'
      
        for i in imagesetlist:
            #print i
            try:
                defmode=i['default']
                figstocapture[i['setenum']]=[]
                for figname in i['sets'][defmode]['figs']:#get default images of default set
                    if 'image' in figname and figname not in figstocapture[i['setenum']]:
                        figstocapture[i['setenum']].append(figname)
                if 'options' in i:#and default options
                    for opt in i['options']:
                        if opt['default']:#checkbox default is true
                            for figname in i['included']:
                                if 'image' in figname and figname not in figstocapture[i['setenum']]:
                                    figstocapture[i['setenum']].append(figname)
            except:
                pass
    else:
        figstocapture=None
    session['figstocapture']=figstocapture
    session['lib_filetype']=None
    picnicsession.storesession(session)
示例#6
0
文件: views.py 项目: CodaP/DplTools
def form_view(request):
    #print 'URLREQ: ',request.matched_route.name
    methodtype=request.matchdict['accesstype']
    methodkey=request.matchdict['access']
    try:
        mylib=HSRLImageArchiveLibrarian(**{methodtype:methodkey})
    except RuntimeError:
        return HTTPNotFound(methodtype + "-" + methodkey + " is invalid")
#        return HTTPTemporaryRedirect(location=request.route_path("home"))
    st=mylib()
    instruments=st['Instruments']
    instcount=len(instruments)
    name=st['Name']
    datasets=[]
    for inst in instruments:
        datasets.extend(lib.instrument(inst)['datasets'])

    try:
        starttime=validdate(int(request.params.getone('byr')),
                            int(request.params.getone('bmo')),
                            int(request.params.getone('bdy')),
                            int(request.params.getone('bhr')),
                            int(request.params.getone('bmn')))
        endtime=validdate(int(request.params.getone('eyr')),
                          int(request.params.getone('emo')),
                          int(request.params.getone('edy')),
                          int(request.params.getone('ehr')),
                          int(request.params.getone('emn')))
        maxalt=float(request.params.getone('maxalt'))
        minalt=float(request.params.getone('minalt'))
    except:
        #print 'fallback'
        #print request.POST
        #print request.GET
        minalt=0
        maxalt=15
        lasttime=mylib.validClosestTime(datetime.utcnow())
        endtime=validdate(lasttime.year,lasttime.month,lasttime.day,lasttime.hour,lasttime.minute-(lasttime.minute%5))
        starttime=validdate(endtime.year,endtime.month,endtime.day,endtime.hour-2,endtime.minute)

    oldformparmsdict={methodtype:methodkey, 'forcematlab':'yes',
                      'byr':'%i' % starttime.year,
                      'bmo':'%i' % starttime.month,
                      'bdy':'%i' % starttime.day,
                      'bhr':'%i' % starttime.hour,
                      'bmn':'%i' % starttime.minute,
                      'eyr':'%i' % endtime.year,
                      'emo':'%i' % endtime.month,
                      'edy':'%i' % endtime.day,
                      'ehr':'%i' % endtime.hour,
                      'emn':'%i' % endtime.minute,
                      'minalt':'%i' % minalt,'maxalt':'%i' % maxalt}
    oldformparams='&'.join((k+'='+oldformparmsdict[k]) for k in oldformparmsdict.keys())
    #print oldformparams

    if request.matched_route.name=='netcdfgen':
        oldurl="http://lidar.ssec.wisc.edu/cgi-bin/processeddata/retrievedata.cgi?%s" % (oldformparams)
    if request.matched_route.name=='imagegen':
        oldurl="http://lidar.ssec.wisc.edu/cgi-bin/ahsrldisplay/requestfigs.cgi?%s" % (oldformparams)
    if False:#instcount>3 :#more than just HSRL. python doesn't support it yet
        return HTTPTemporaryRedirect(location=oldurl)


    #print request
    # used in both forms, but simplifies template
    alts=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,20,25,30] #in kilometers
    # these are only used in netcdf, and not form-configurable. this simplifies the template
    altres=30
    timeres=30
    altresvals=[7.5,15,30,45,60,75,90,120,150,300,450,600,900,1200] # in meters
    timeresvals=[2.5,5,10,15,30,60,120,180,240,300,600,900,1200,3600,43200] # in seconds

                                                                            #print instruments

    hosttouse=None
    porttouse=None
    if "X-Forwarded-Host" in request.headers:
        hosttouse=request.headers['X-Forwarded-Host']
        porttouse=''

    return {'project':'Picnic',
            'bdate':starttime,
            'edate':endtime,'calendar':calendar,'timedelta':timedelta,'datetime':datetime,
            'altrange':[minalt,maxalt],'alts':alts,
            'timeresvals':timeresvals,'altresvals':altresvals,
            'timeres':timeres,'altres':altres,
            'imagesets':jsgen.formsetsForInstruments(datasets,'images'),
            'netcdfsets':jsgen.formsetsForInstruments(datasets,'netcdf'),
            'datasets':datasets,'method':methodtype,methodtype:methodkey,
            'oldurl':oldurl,
            'netcdfdestinationurl':request.route_url('netcdfreq',_host=hosttouse,_port=porttouse),
            'imagedestinationurl':request.route_url('imagereq',_host=hosttouse,_port=porttouse),
            'cdltemplates':{
                "hsrl_nomenclature.cdl":"UW HSRL(NetCDF4)",
                "hsrl_cfradial.cdl":"NCAR CFRadial",
                "hsrl3_processed.cdl":"UW Processed (NetCDF3)",
                "hsrl3_raw.cdl":"UW Raw (NetCDF3)",
                "custom":"User Provided:"
            },
            'cdltemplateorder':[ "hsrl_nomenclature.cdl","hsrl_cfradial.cdl","hsrl3_processed.cdl","hsrl3_raw.cdl","custom"],
            'userTracking':picnicsession.haveUserTracking(),
            #'usercheckurl':request.route_path('userCheck'),#'http://lidar.ssec.wisc.edu/cgi-bin/util/userCheck.cgi',
            'dataAvailabilityURL':request.route_path('dataAvailability'),
            'sitename':name,'setCount':setCount,'setGen':setGen,'make_archived_widget':server_archive.make_archived_widget,'archived_widget_head':server_archive.archived_widget_head}