source: cows_wps/trunk/cows_wps/utils/axis_sorting.py @ 5615

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/cows_wps/trunk/cows_wps/utils/axis_sorting.py@7575
Revision 5615, 776 bytes checked in by spascoe, 10 years ago (diff)

COWS WPS package copied from
 http://proj.badc.rl.ac.uk/svn/dcip/cows-wps/trunk.

This is a stripped down version of the DDP WPS. Some features are
removed and others have been deactivated until we reimplement them in a
more generic way.

Line 
1
2import ddp.utils.mappings as mappings
3
4def sortTimeSlices(timeSlices):
5   
6    if type(timeSlices) == str or len(timeSlices) == 1:
7        return timeSlices   
8   
9    return sorted(timeSlices)
10
11def _emScenCompare(a,b):
12    emScens = list(mappings.em_scens)
13   
14    return cmp(emScens.index(a), emScens.index(b))
15
16def sortEmissionScenarios(emScens):
17   
18    if type(emScens) == str or len(emScens) == 1:
19        return emScens   
20   
21    return sorted(emScens, cmp=_emScenCompare)
22
23def _mpsCompare(a, b):
24    meaningPeriods = list(mappings.meaning_periods)
25   
26    return cmp(meaningPeriods.index(a) , meaningPeriods.index(b))
27
28def sortMeaningPeriods(mps):
29   
30    if type(mps) == str or len(mps) == 1:
31        return mps
32   
33    return sorted(mps, cmp=_mpsCompare)
Note: See TracBrowser for help on using the repository browser.