Question: Part 1: Write a function, microcar, which accepts two inputs. The two inputs are two lists of strings containing names of CSV files (including locations

Part 1:

Write a function, microcar, which accepts two inputs. The two inputs are two lists of strings containing names of CSV files (including locations if files are not in the same folder where file containing the function is stored): the first list contains the names of the files (including locations if required) containing the instructions for each microcar and, the second list contains the names of the files (including locations if required) containing the actual actions of each care corresponding to the instructions provided to them.

The two csv files will contain lines in the following format: Action, time, speed - where each action will be specified as:

N, t, s = Move North for t seconds with speed s meters per second

E, t, s = Move East for t seconds with speed s meters per second

W, t, s = Move West for t seconds with speed s meters per second

S, t, s = Move South for t seconds with speed s meters per second

The function will return six numpy arrays:

The expected horizontal displacements for each microcar

The expected vertical displacements for each microcar

The actual horizontal displacements for each microcar

The actual vertical displacements for each microcar

The expected distances traveled by each microcar

The actual distances traveled by each microcar

All displacements and distances are to be presented in meters and rounded to 2 decimal places for the final returned lists. Keep the data rounded to at least 10 decimal places for all intermediate computations.

Additionally the data will adhere to the following constraints:

There will never be a missing instruction. The number of expected and actual instructions will always match.

Both files will contain valid instructions only.

Part 2:

In addition to the function described above, write a second function plotmicrocar which will accept the same arguments and perform the same calculations as before but will additionally create the following plots:

A bar-plot comparing the expected and actual distance covered by each microcar.

A scatter-plot of the expected final horizontal and vertical displacements for each microcar.

A scatter-plot of the actual final horizontal and vertical displacements for each microcar.

We expect these plots to be generated as sub-plots and match the example templates. You need to ensure that scatter plots are square in size and have same dimensions for easy of understanding of the results. In addition, the dimensions should be larger enough such that microcar displacements should not be at the corner of the plots. Dont forget the guidelines of plots explained to you during the lectures.

Note: when writing plotmicrocar function, dont re-write your code. Make a function call to your original microcar function to generate your data.

Examples and Sample Data:

The sample plot is presented for guidance. Remember the data presented in the chart is sample only and is not correct or related to the sample data files.

Act 1

N

10

18

E 9 8
S 10 16
W 9 5

Act 2

S 20 8
W 11 11
N 14 13
E 18 10
N 9 9
E 6 13
S 10 8
W 10 10

Exp 1

N 10 10
E 10 8
S 10 5
W 10 4

Exp 2

S 20 10 W 10 12 N 15 12 E 20 8 N 10 8 E 5 15 S 10 10 W 10 8

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!