Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI02-CSML/trunk/csml/API/csmlutils.py@2081
Revision 2081,
933 bytes
checked in by domlowe, 14 years ago
(diff) |
subsetting seems to be working, but needs more testing and tidying of code
|
Line | |
---|
1 | '''csml utils contains useful utility functions''' |
---|
2 | |
---|
3 | |
---|
4 | def listify(item): |
---|
5 | ''' listify checks if an item is a list, if it isn't it puts it inside a list and returns it. Always returns a list object''' |
---|
6 | if type(item) is list: |
---|
7 | return item |
---|
8 | else: |
---|
9 | return [item] |
---|
10 | |
---|
11 | |
---|
12 | |
---|
13 | #deal with longitude requests |
---|
14 | #if the request is in -ve,+ve eg (-30,30) but the data is in (0,360) need to handle this by changing the args. |
---|
15 | def fixLongitude(request, kwargs): |
---|
16 | for key in request.keys(): |
---|
17 | if key == 'Lon': #how do we test if it is longitude properly? |
---|
18 | for val in request[key]: |
---|
19 | if val < 0: |
---|
20 | pass |
---|
21 | else: |
---|
22 | if kwargs[key][0] < 0: |
---|
23 | kwargs[key]=(kwargs[key][0]+360,kwargs[key][1]) |
---|
24 | if kwargs[key][1] < 0: |
---|
25 | kwargs[key]=(kwargs[key][0],kwargs[key][1]+360) |
---|
26 | return kwargs |
---|
Note: See
TracBrowser
for help on using the repository browser.