-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutility.py
50 lines (41 loc) · 1.11 KB
/
utility.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# -*- coding: utf-8 -*-
"""
Created on Thu Apr 15 11:12:09 2021
@author: Quentin
"""
import sys
import os
import numpy as np
# return a list of the name of all the files in path
# with all the strings in lookFor in their name
def listFiles(path,lookFor):
fileList = os.listdir(path)
matching=[]
for f in fileList:
condition=1
for i in range(len(lookFor)):
if lookFor[i] not in f:
condition=condition*0
if condition==1:
matching.append(f)
return matching
# convert (X,Y) position (0.0 to 1.0) into 0-15 id (represents a 4x4 grid)
#
# 0-------------------> [x=1]
# | ------------------
# | | 0 | 1 | 2 | 3 |
# | ------------------
# | | 4 | 5 | 6 | 7 |
# | ------------------
# | | 8 | 9 |10 |11 |
# | ------------------
# | |12 |13 |14 |15 |
# | ------------------
# V [y=1]
def XYtoID(position):
x=position[0]
y=position[1]
x=np.ceil((x+0.05)*4 -1)
y=np.ceil((y+0.05)*4 -1)
return np.abs(x+(4*y))
# %%