Skip to content
Snippets Groups Projects
Commit 1e0c997a authored by vkarve2's avatar vkarve2
Browse files

Added a Git_Workflow and signature plot functions.

parent 08ca0c1e
No related branches found
No related tags found
No related merge requests found
# This is documentation on how to use Git (Gitlab) commands to contribute code to the Manhattan Traffic Project.
Author: Vaibhav Karve Last Modifoed: 2017-01-01
### Disclaimer: I am still a noob and there might be mistakes born due to my incorrectly understanding how git works. Let me know if you have any questions, or if things don't work out the way I say they would. -- Vaibhav Karve
## Requirements:
- Terminal or Command-Prompt
- Make sure git is installed on your computer.
## For setting up the repository on your local machine: (You need to do this only the first time)
1. In your local machine, navigate to a location where you wish to create a local copy of the repository.
2. Run the command: `git clone https://gitlab.engr.illinois.edu/r-sowers/TrafficPatterns.git`.
- This will create a copy of the remote GitLab repository (called `origin`) into your local machine (in a folder called `TrafficPatterns`).
- It will also create a hidden `.git` folder within `TrafficPatterns`.
- You might have to enter your username and password here for authorization.
- You now have a working copy of the repository including all its branches.
- (To undo this step, simply delete the folder from your local machine.)
## Helpful commands that you can run at any time without it messing with your files:
- `git fetch`
- `git branch`
- `git status`
- `git log --oneline --decorate --graph`
## If now you wish to change some part of the code: (You need to repeat these steps every time you start working on the code.)
3. Always start by running the command `git fetch`.
- This updates your local repository with any new changes that anyone else might have pushed to GitLab since the last time you updates the repository.
- This command is perfectly safe to run as it does not overwrite anything and causes no loss of data. It is just a way of syncing your git history with that of the remote repository.
- Run this as often as you wish, even while in the middle of working on something. The more the better.
4. Before you start editing anything, create a new branch. This keeps any changes you make out of the master branch till you are ready to merge in the new changes.
- Run the command `git branch dumbidea` to create a branch called `dumbidea`.
- To check if this worked, run `git branch` to create a list of branch with an asterix next to the branch you are currently on.
- Note that the default branch is called `master`.
- (You can undo this step by running `git branch -d dumbidea`. This will delete the branch you just created.)
5. Switch to the branch you created in Step 4. by running `git checkout dumbidea`.
- (You can undo this step and switch back to master by running `git checkout master`).
- *Important:* every time you switch branches, the files on your local machine will change to reflect the state of the files in that particular branch.
6. Make the changes you wish to make to any files you want. Say you changed `A.txt`, `B.txt` and `C.txt`.
- If at any point you wish to revisit or view the old file (beofe your changes), you can access the old version simply by switching back to master branch (`git checkout master`). Make sure you switch back to your `dumbidea` branch before making more changes.
- You can review which files you have changed by running `git status`.
- You can review which changes you made in a particular file by running say `git diff C.txt`.
- If you are dissatisfied by the changes you made to say `C.txt`, simply run `git checkout C.txt` to revert back to the state of the file as it was during the previous commit. This will undo any changes. (You cannot undo this undo-ing. So be careful. Run the `git checkout C.txt` command only if you are sure you want to discard any changes you made.)
7. Stage the changes you do wish to keep. This is done by running `git add path/to/file`
- Throughout the following steps, you can always run `git status` to keep track of which files have been modified, which have been staged, and which have been committed.
- Staging the file is like saying "I am happy with the changes I have made and would like to start the process of creating a check-point for the files at this point."
- (You can undo this step by running `git reset HEAD path/to/file`.
- If you are done editing `A.txt` but are still working on `B.txt`, it is okay to stage only `A.txt`. Even if you edit `A.txt` after staging, you can always re-stage it by typing `git add A.txt`.
8. Once all files have been staged, we are ready to commit our changes by running `git commit dumbidea`:
- This is a local commit! This will only commit on our local machine and will not affect what is present on GitLab. Think of this as an extra layer of security before your `dumbidea` start affecting everyone else.
- You will be prompted with a message window where you should type out your commit message in as meaningful a way as possible.
- Check that your commit was successful by running `git status`. You should now see a message that says `your branch is 1 commit ahead of origin/master`.
- (If you wish to undo this commit, look at the next to steps depending on whether you wish to do a soft or hard undo).
9. If you decide that you committed the file too soon and would like to undo just the commit but keep all the edits you might have made to the file:
- Run `git reset HEAD~1`
- This takes you back to how things were at the end of Step 7. i.e. files are staged but not committed.
- (To undo this undo-ing, simply repeat Step 8.)
10. If you decide that the commit you made in step 8. is complete rubbish and you want to erase all history of the edits that were made since the commit before that, you need a hard reset.
- Run `git reset --hard HEAD~1`
- (This undo-ing is hard to undo, but possible. Just be careful before doing a hard reset.)
11. I am happy with my commit and now I would like everyone to be able to see it on GitLab:
- If you are done with Step 8. and haven't had the need to run Steps 9. and 10., then you can run `git push` to push your changes to the remote repository (i.e. this will update `origin`).
- (If you wish to undo this, it is going to be difficult, but not impossible. First, inform everyone on your team to hold off and not work with your erroneous files. Next, start Googling for ways to undo the `git push` commands.)
12. Repeat Steps 6. to 11. as many times as you want in order to make further changes to your `dumbidea` branch.
- Keep running `git fetch` in order to remain up-to-date with GitLab.
13. Once you are completely confident that `dumbidea` is actually not-so-dumb-afterall, you can decide to merge it into the `master` branch.
- Switch to master branch by running `git checkout master`.
- To merge your branch with master, run `git merge dumbidea`.
- If this process works out smoothly without displaying any Conflict messages, then you can move to Step 15.
14. If some other user (or you yourself) have made changes to the master branch that are not compatible with changes that you have made to files in `dumbidea` then Git will automatically detect this as a conflict and not allow you to merge till you resolve all the conflict. If this happens, do the following:
- Open the files that Git has indicated as having conflicts in them, say `A.txt`. In `A.txt`, Git will have marked the specific lines that are in conflict as follows:
```
<<<<<<< HEAD:A.txt
This is the line that was in the master branch.
=======
This is the line that is in the dumbidea branch.
>>>>>>> dumbidea:A.txt
```
- Replace the block of text specified above with either the version in `master` branch, the version in `dumbidea` branch, or a mixure of both versions.
- Make sure to completely remove the <<<<<<<, ======= and >>>>>>> lines.
- After resolving each section in each conflicted file, run `git add` on each file to mark it as resolved and to stage it.
- Run `git commit` without any conflict messages.
15. Cleaning up after you are done using your branch.
- After you have successfully merged a branch into `master`, you can get rid of the `dumbidea` branch by running `git branch -d dumbidea`.
- This will clean up the branch history.
- You can check that the branch has been deleted by running `git branch`.
16. Next time you want to edit something, start again at Step 4.
%% Cell type:code id: tags:
``` python
import numpy as np
import pandas as pd
import config
import matplotlib.pyplot as plt
%matplotlib inline
```
%% Cell type:markdown id: tags:
# This notebook is used for visualizing the results from cSNMF.ipynb
Map visualizations require links.csv from ??????
We do the following visualizations:
- Plot of each signature, for every day of the week (70 sigs $\times$ 7 days)
- Map of all links for each signature
- Map of all links that use 7+ signatures
%% Cell type:code id: tags:
``` python
W = np.loadtxt('W_trips.txt')
for column in W.T:
signature = column.reshape((len(column)//24, 24))
for day, entry in enumerate(signature):
day_of_week = day%7
# Day 0 is Saturday
if day_of_week == 2:
plt.plot(range(24), entry, 'g')
break
```
%% Output
%% Cell type:code id: tags:
``` python
import geopandas as gpd
import numpy as np
from shapely.geometry import LineString
import config
filenames = config.generate_filenames('')
full_link_ids = np.loadtxt('full_link_ids.txt', dtype=int)
crs = {'init': 'epsg:4326'}
```
%% Cell type:code id: tags:
``` python
H_loaded = gpd.pd.read_csv(filenames['H_trips'], delimiter=' ', names=full_link_ids)
H_loaded
```
%% Output
790 1542 1646 1880 2293 \
0 243200.130650 833200.140566 105241.586775 441696.197462 509170.477893
1 0.000000 0.000000 0.000000 0.000000 0.000000
2 0.000000 0.000000 137819.066562 214007.272583 171835.422655
3 0.000000 0.000000 0.000000 0.000000 0.000000
4 0.000000 797229.053560 0.000000 0.000000 0.000000
5 0.000000 0.000000 0.000000 0.000000 0.000000
6 65363.115683 0.000000 0.000000 134267.561629 0.000000
7 0.000000 0.000000 0.000000 0.000000 0.000000
8 80448.276676 0.000000 0.000000 140211.043568 0.000000
9 0.000000 0.000000 0.000000 0.000000 0.000000
10 0.000000 0.000000 0.000000 0.000000 0.000000
11 0.000000 0.000000 0.000000 0.000000 0.000000
12 75596.468427 0.000000 0.000000 118629.088172 0.000000
13 0.000000 0.000000 0.000000 0.000000 0.000000
14 0.000000 0.000000 0.000000 0.000000 0.000000
15 0.000000 0.000000 0.000000 0.000000 0.000000
16 0.000000 0.000000 0.000000 0.000000 0.000000
17 0.000000 0.000000 0.000000 0.000000 0.000000
18 0.000000 0.000000 27917.383902 0.000000 382604.598787
19 0.000000 0.000000 0.000000 0.000000 0.000000
20 0.000000 0.000000 0.000000 0.000000 159377.349581
21 0.000000 0.000000 0.000000 0.000000 0.000000
22 0.000000 0.000000 0.000000 0.000000 0.000000
23 0.000000 0.000000 72012.131393 0.000000 0.000000
24 0.000000 0.000000 0.000000 0.000000 0.000000
25 0.000000 0.000000 0.000000 0.000000 0.000000
26 0.000000 0.000000 0.000000 0.000000 0.000000
27 0.000000 0.000000 0.000000 0.000000 0.000000
28 0.000000 488910.363998 0.000000 0.000000 0.000000
29 0.000000 0.000000 0.000000 0.000000 0.000000
.. ... ... ... ... ...
40 0.000000 0.000000 0.000000 0.000000 0.000000
41 0.000000 0.000000 0.000000 0.000000 0.000000
42 0.000000 0.000000 0.000000 0.000000 0.000000
43 0.000000 0.000000 0.000000 0.000000 0.000000
44 0.000000 0.000000 0.000000 0.000000 0.000000
45 0.000000 0.000000 0.000000 0.000000 0.000000
46 0.000000 0.000000 0.000000 0.000000 0.000000
47 0.000000 0.000000 0.000000 0.000000 0.000000
48 0.000000 0.000000 0.000000 0.000000 0.000000
49 0.000000 0.000000 0.000000 0.000000 0.000000
50 0.000000 0.000000 0.000000 0.000000 0.000000
51 0.000000 0.000000 0.000000 0.000000 0.000000
52 0.000000 0.000000 0.000000 0.000000 0.000000
53 0.000000 0.000000 0.000000 0.000000 0.000000
54 0.000000 0.000000 0.000000 0.000000 0.000000
55 0.000000 0.000000 0.000000 0.000000 0.000000
56 0.000000 0.000000 0.000000 0.000000 0.000000
57 0.000000 0.000000 0.000000 0.000000 0.000000
58 0.000000 0.000000 0.000000 0.000000 0.000000
59 0.000000 0.000000 0.000000 0.000000 0.000000
60 0.000000 0.000000 0.000000 0.000000 0.000000
61 0.000000 0.000000 0.000000 0.000000 0.000000
62 0.000000 0.000000 0.000000 0.000000 0.000000
63 0.000000 0.000000 0.000000 0.000000 0.000000
64 0.000000 0.000000 0.000000 0.000000 0.000000
65 0.000000 0.000000 0.000000 0.000000 0.000000
66 0.000000 0.000000 0.000000 0.000000 0.000000
67 0.000000 0.000000 0.000000 0.000000 0.000000
68 0.000000 0.000000 0.000000 0.000000 0.000000
69 0.000000 0.000000 0.000000 0.000000 0.000000
2568 2894 3330 3503 3600 \
0 0.000000 0.000000 0.000000 0.000000 0.000000
1 0.000000 0.000000 0.000000 0.000000 127301.151657
2 109841.093306 377576.699268 72474.047382 244546.501576 0.000000
3 0.000000 0.000000 0.000000 0.000000 441925.479448
4 0.000000 0.000000 0.000000 0.000000 136233.183006
5 189280.793954 175579.555496 210342.933594 182870.304925 0.000000
6 117665.402524 140201.944085 106028.533158 147129.487132 0.000000
7 0.000000 0.000000 0.000000 0.000000 0.000000
8 0.000000 0.000000 0.000000 0.000000 0.000000
9 0.000000 0.000000 0.000000 0.000000 0.000000
10 0.000000 0.000000 0.000000 0.000000 0.000000
11 0.000000 0.000000 0.000000 0.000000 0.000000
12 0.000000 0.000000 0.000000 0.000000 0.000000
13 0.000000 0.000000 0.000000 0.000000 0.000000
14 0.000000 0.000000 0.000000 0.000000 0.000000
15 0.000000 0.000000 0.000000 0.000000 740308.324937
16 0.000000 0.000000 0.000000 0.000000 0.000000
17 0.000000 0.000000 0.000000 0.000000 0.000000
18 0.000000 0.000000 0.000000 0.000000 0.000000
19 0.000000 0.000000 0.000000 0.000000 0.000000
20 0.000000 0.000000 0.000000 0.000000 0.000000
21 0.000000 0.000000 0.000000 0.000000 0.000000
22 0.000000 0.000000 0.000000 0.000000 0.000000
23 0.000000 0.000000 0.000000 0.000000 0.000000
24 0.000000 0.000000 0.000000 0.000000 0.000000
25 86061.559249 0.000000 69284.297516 0.000000 0.000000
26 0.000000 0.000000 0.000000 0.000000 0.000000
27 0.000000 0.000000 0.000000 0.000000 0.000000
28 0.000000 0.000000 0.000000 0.000000 0.000000
29 0.000000 0.000000 0.000000 0.000000 0.000000
.. ... ... ... ... ...
40 0.000000 0.000000 0.000000 0.000000 0.000000
41 0.000000 0.000000 0.000000 0.000000 0.000000
42 0.000000 0.000000 0.000000 0.000000 0.000000
43 0.000000 0.000000 0.000000 0.000000 0.000000
44 0.000000 0.000000 0.000000 0.000000 0.000000
45 0.000000 0.000000 0.000000 0.000000 0.000000
46 0.000000 0.000000 0.000000 0.000000 0.000000
47 0.000000 0.000000 0.000000 0.000000 0.000000
48 0.000000 0.000000 0.000000 0.000000 0.000000
49 0.000000 0.000000 0.000000 0.000000 0.000000
50 0.000000 0.000000 0.000000 0.000000 0.000000
51 0.000000 0.000000 0.000000 0.000000 0.000000
52 0.000000 0.000000 0.000000 0.000000 0.000000
53 0.000000 0.000000 0.000000 0.000000 0.000000
54 0.000000 0.000000 0.000000 0.000000 0.000000
55 0.000000 0.000000 0.000000 0.000000 0.000000
56 0.000000 0.000000 0.000000 0.000000 0.000000
57 0.000000 0.000000 0.000000 0.000000 0.000000
58 0.000000 0.000000 0.000000 0.000000 0.000000
59 0.000000 0.000000 0.000000 0.000000 0.000000
60 0.000000 0.000000 0.000000 0.000000 0.000000
61 0.000000 0.000000 0.000000 0.000000 0.000000
62 0.000000 0.000000 0.000000 0.000000 0.000000
63 0.000000 0.000000 0.000000 0.000000 0.000000
64 0.000000 0.000000 0.000000 0.000000 0.000000
65 0.000000 0.000000 0.000000 0.000000 0.000000
66 0.000000 0.000000 0.000000 0.000000 0.000000
67 0.000000 0.000000 0.000000 0.000000 0.000000
68 0.000000 0.000000 0.000000 0.000000 0.000000
69 0.000000 0.000000 0.000000 0.000000 0.000000
... 257676 257803 257952 258277 \
0 ... 0.000000 0.000000 0.000000 0.000000
1 ... 373494.299942 487989.729912 224975.465519 248606.634180
2 ... 0.000000 0.000000 0.000000 0.000000
3 ... 0.000000 0.000000 0.000000 0.000000
4 ... 0.000000 0.000000 0.000000 0.000000
5 ... 0.000000 0.000000 0.000000 0.000000
6 ... 0.000000 0.000000 0.000000 0.000000
7 ... 0.000000 0.000000 0.000000 0.000000
8 ... 0.000000 0.000000 0.000000 0.000000
9 ... 0.000000 0.000000 0.000000 0.000000
10 ... 0.000000 0.000000 0.000000 0.000000
11 ... 678219.213730 638452.314453 118203.444211 342724.388895
12 ... 0.000000 0.000000 0.000000 0.000000
13 ... 0.000000 0.000000 0.000000 0.000000
14 ... 0.000000 0.000000 0.000000 0.000000
15 ... 0.000000 0.000000 0.000000 0.000000
16 ... 0.000000 0.000000 0.000000 0.000000
17 ... 0.000000 0.000000 0.000000 0.000000
18 ... 0.000000 0.000000 0.000000 0.000000
19 ... 0.000000 0.000000 0.000000 0.000000
20 ... 0.000000 0.000000 0.000000 0.000000
21 ... 0.000000 0.000000 0.000000 0.000000
22 ... 0.000000 0.000000 0.000000 0.000000
23 ... 0.000000 0.000000 0.000000 0.000000
24 ... 0.000000 0.000000 0.000000 0.000000
25 ... 0.000000 0.000000 0.000000 0.000000
26 ... 0.000000 0.000000 0.000000 0.000000
27 ... 0.000000 0.000000 0.000000 0.000000
28 ... 0.000000 0.000000 0.000000 0.000000
29 ... 0.000000 0.000000 0.000000 0.000000
.. ... ... ... ... ...
40 ... 0.000000 0.000000 0.000000 0.000000
41 ... 0.000000 0.000000 0.000000 0.000000
42 ... 0.000000 0.000000 0.000000 0.000000
43 ... 0.000000 0.000000 0.000000 0.000000
44 ... 0.000000 0.000000 0.000000 0.000000
45 ... 0.000000 0.000000 0.000000 0.000000
46 ... 0.000000 0.000000 0.000000 0.000000
47 ... 0.000000 0.000000 0.000000 0.000000
48 ... 0.000000 0.000000 0.000000 0.000000
49 ... 0.000000 0.000000 0.000000 0.000000
50 ... 0.000000 0.000000 0.000000 0.000000
51 ... 0.000000 0.000000 0.000000 0.000000
52 ... 0.000000 0.000000 0.000000 0.000000
53 ... 0.000000 0.000000 0.000000 0.000000
54 ... 0.000000 0.000000 0.000000 0.000000
55 ... 0.000000 0.000000 0.000000 0.000000
56 ... 0.000000 0.000000 0.000000 0.000000
57 ... 0.000000 0.000000 0.000000 0.000000
58 ... 0.000000 0.000000 0.000000 0.000000
59 ... 0.000000 0.000000 0.000000 0.000000
60 ... 0.000000 0.000000 0.000000 0.000000
61 ... 0.000000 0.000000 0.000000 0.000000
62 ... 0.000000 0.000000 0.000000 0.000000
63 ... 0.000000 0.000000 0.000000 0.000000
64 ... 0.000000 0.000000 0.000000 0.000000
65 ... 0.000000 0.000000 0.000000 0.000000
66 ... 0.000000 0.000000 0.000000 0.000000
67 ... 0.000000 0.000000 0.000000 0.000000
68 ... 0.000000 0.000000 0.000000 0.000000
69 ... 0.000000 0.000000 0.000000 0.000000
258494 258561 259225 259250 259766 \
0 395322.615077 0.000000 0.000000 0.000000 0.000000
1 0.000000 29164.437483 0.000000 0.000000 0.000000
2 510726.018286 99573.842376 0.000000 0.000000 0.000000
3 0.000000 0.000000 0.000000 0.000000 0.000000
4 0.000000 22777.365201 0.000000 0.000000 0.000000
5 0.000000 0.000000 0.000000 0.000000 0.000000
6 186628.849969 12322.727332 0.000000 0.000000 0.000000
7 0.000000 19249.301700 0.000000 0.000000 0.000000
8 150757.300750 0.000000 0.000000 0.000000 0.000000
9 0.000000 0.000000 0.000000 0.000000 0.000000
10 0.000000 0.000000 0.000000 0.000000 0.000000
11 0.000000 0.000000 0.000000 0.000000 0.000000
12 0.000000 0.000000 0.000000 0.000000 0.000000
13 0.000000 0.000000 0.000000 0.000000 0.000000
14 0.000000 30365.724210 0.000000 0.000000 0.000000
15 0.000000 23168.873355 0.000000 0.000000 0.000000
16 0.000000 0.000000 0.000000 0.000000 0.000000
17 0.000000 23029.256025 0.000000 0.000000 0.000000
18 0.000000 0.000000 0.000000 0.000000 0.000000
19 0.000000 0.000000 0.000000 0.000000 0.000000
20 0.000000 0.000000 0.000000 0.000000 0.000000
21 0.000000 0.000000 0.000000 0.000000 0.000000
22 0.000000 0.000000 0.000000 0.000000 0.000000
23 0.000000 0.000000 0.000000 0.000000 0.000000
24 0.000000 0.000000 0.000000 0.000000 0.000000
25 0.000000 0.000000 0.000000 0.000000 0.000000
26 0.000000 0.000000 0.000000 0.000000 0.000000
27 0.000000 0.000000 985941.611673 939910.324878 944384.715148
28 0.000000 0.000000 0.000000 0.000000 0.000000
29 0.000000 0.000000 0.000000 0.000000 0.000000
.. ... ... ... ... ...
40 0.000000 0.000000 0.000000 0.000000 0.000000
41 0.000000 0.000000 0.000000 0.000000 0.000000
42 0.000000 0.000000 0.000000 0.000000 0.000000
43 0.000000 0.000000 0.000000 0.000000 0.000000
44 0.000000 0.000000 0.000000 0.000000 0.000000
45 0.000000 0.000000 0.000000 0.000000 0.000000
46 0.000000 0.000000 0.000000 0.000000 0.000000
47 0.000000 0.000000 0.000000 0.000000 0.000000
48 0.000000 0.000000 0.000000 0.000000 0.000000
49 0.000000 0.000000 0.000000 0.000000 0.000000
50 0.000000 0.000000 0.000000 0.000000 0.000000
51 0.000000 0.000000 0.000000 0.000000 0.000000
52 0.000000 0.000000 0.000000 0.000000 0.000000
53 0.000000 0.000000 0.000000 0.000000 0.000000
54 0.000000 0.000000 0.000000 0.000000 0.000000
55 0.000000 0.000000 0.000000 0.000000 0.000000
56 0.000000 0.000000 0.000000 0.000000 0.000000
57 0.000000 0.000000 0.000000 0.000000 0.000000
58 0.000000 0.000000 0.000000 0.000000 0.000000
59 0.000000 0.000000 0.000000 0.000000 0.000000
60 0.000000 0.000000 0.000000 0.000000 0.000000
61 0.000000 0.000000 0.000000 0.000000 0.000000
62 0.000000 0.000000 0.000000 0.000000 0.000000
63 0.000000 0.000000 0.000000 0.000000 0.000000
64 0.000000 0.000000 0.000000 0.000000 0.000000
65 0.000000 0.000000 0.000000 0.000000 0.000000
66 0.000000 0.000000 0.000000 0.000000 0.000000
67 0.000000 0.000000 0.000000 0.000000 0.000000
68 0.000000 0.000000 0.000000 0.000000 0.000000
69 0.000000 0.000000 0.000000 0.000000 0.000000
259906
0 138071.804891
1 0.000000
2 42041.892101
3 27377.001392
4 0.000000
5 51189.825880
6 16408.888842
7 45470.497394
8 0.000000
9 0.000000
10 19869.674213
11 0.000000
12 0.000000
13 0.000000
14 0.000000
15 0.000000
16 0.000000
17 0.000000
18 0.000000
19 0.000000
20 0.000000
21 0.000000
22 0.000000
23 0.000000
24 0.000000
25 0.000000
26 0.000000
27 0.000000
28 0.000000
29 0.000000
.. ...
40 0.000000
41 0.000000
42 0.000000
43 0.000000
44 0.000000
45 0.000000
46 0.000000
47 0.000000
48 0.000000
49 0.000000
50 0.000000
51 0.000000
52 0.000000
53 0.000000
54 0.000000
55 0.000000
56 0.000000
57 0.000000
58 0.000000
59 0.000000
60 0.000000
61 0.000000
62 0.000000
63 0.000000
64 0.000000
65 0.000000
66 0.000000
67 0.000000
68 0.000000
69 0.000000
[70 rows x 2302 columns]
%% Cell type:code id: tags:
``` python
signature_link_lists = list()
link_df = gpd.pd.read_csv(filenames['links'])
for signature in range(config.RANK):
signature_list = H_loaded.loc[signature,:][H_loaded.loc[signature,:]>0].keys().tolist()
signature_link_lists.append(signature_list)
if len(signature_list)>0:
df = link_df[link_df['link_id'].isin(signature_link_lists[signature])]
df['geom'] = df.apply(lambda x: LineString([(x.startX,x.startY),(x.endX,x.endY)]), axis=1)
geo_df = gpd.GeoDataFrame(df, crs=crs, geometry='geom')
location = 'Signature_Maps\sig' + format(signature, '02d')
geo_df.to_file(location)
else:
print('Signature'+str(signature)+'has no links')
```
%% Output
C:\Users\yager\Anaconda3\lib\site-packages\ipykernel_launcher.py:9: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
if __name__ == '__main__':
Signature46has no links
Signature47has no links
Signature48has no links
Signature49has no links
Signature50has no links
Signature51has no links
Signature52has no links
Signature53has no links
Signature54has no links
Signature55has no links
Signature56has no links
Signature57has no links
Signature58has no links
Signature59has no links
Signature60has no links
Signature61has no links
Signature62has no links
Signature63has no links
Signature64has no links
Signature65has no links
Signature66has no links
Signature67has no links
Signature68has no links
Signature69has no links
%% Cell type:code id: tags:
``` python
H_loaded.loc[69].sum()
```
%% Output
0.0
%% Cell type:code id: tags:
``` python
threshold = 7 # for number of signatures for a link considered high
ds = np.sum(H_loaded>0, axis=0)
link_ids_with_high_signature_count = ds[ds>=threshold].keys().tolist()
```
%% Cell type:code id: tags:
``` python
link_df = gpd.pd.read_csv(filenames['links'])
df = link_df[link_df['link_id'].isin(link_ids_with_high_signature_count)]
df['geom'] = df.apply(lambda x: LineString([(x.startX,x.startY),(x.endX,x.endY)]), axis=1)
geo_df = gpd.GeoDataFrame(df, crs=crs, geometry='geom')
geo_df.to_file('High_Signature_Map')
```
%% Output
C:\Users\yager\Anaconda3\lib\site-packages\ipykernel_launcher.py:3: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
This is separate from the ipykernel package so we can avoid doing imports until
%% Cell type:markdown id: tags:
# Temporal visualizations:
%% Cell type:code id: tags:
``` python
import numpy as np
import Visualizations
W = np.loadtxt('W_trips.txt')
Visualizations.plot_all_signatures_particular_weekday(W, 1, mean = True)
```
......
......@@ -30,7 +30,7 @@ def plot_all_weekdays(w, mean = False, signature = '??'):
fig = plt.figure(figsize = (16, 9)) # size in inches
for weekday in range(0, 7):
plot_particular_weekday(w, weekday, mean = mean)
imagename = '../Figures/' + str(signature).zfill(2) + days_of_week[weekday][0:3] + '.png'
imagename = './Images/Signature_Trends/' + str(signature).zfill(2) + days_of_week[weekday][0:3] + '.png'
plt.savefig(imagename, dpi=300, bbox_inches='tight') # dpi ideal for viewing on laptop fullscreen
plt.clf()
......@@ -40,7 +40,7 @@ def plot_all_signatures_particular_weekday(W, weekday, mean = False):
fig = plt.figure(figsize = (16, 9)) # size in inches
for signature in range(config.RANK):
plot_particular_weekday(W[:, signature], weekday, mean = mean)
imagename = '../Figures/' + str(signature).zfill(2) + days_of_week[weekday][0:3] + '.png'
imagename = './Images/Signature_Trends/' + str(signature).zfill(2) + days_of_week[weekday][0:3] + '.png'
plt.savefig(imagename, dpi=300, bbox_inches='tight') # dpi ideal for viewing on laptop fullscreen
plt.clf()
......
This diff is collapsed.
......@@ -182,4 +182,4 @@ def factorize(data_array,
sparsity = sparsity_metric(H)
log.info('Error= %s, Sparsity= %s', error, sparsity)
return W, H, results[column_names], error
return W, H, results[column_names]
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment