Final Assessment
Your university is collaborating with a company to develop a tool for processing reports of cases of a particular disease. The company has a very specific way of doing things, and has asked you to design and build a JavaScript object to interact with their proprietary code. Your supervisor wants you to submit an example of your code working within a Jupyter notebook her preferred environment! so she can review it before sending it off to the company.
There are three input datasets, so you can play with them to make sure your code is robust.
Rememberyour code will be tested against other input data, so make sure that you are being careful in your assumptions!
We also give you an example of sampleoutput.txt, which would be useful for Task 3. Remember, you will need to overwrite this file.
Also rememberdont use any packagelibrary including but not limited to numpyscipycsv. You should finish these tasks without these packages.
Task 1
You have been provided with a sample of the case incidence records to help you test your code in the file sampleCases.tsv. The company has done a questionable job of digitising these records, however, and you will need to clean them up a bit before you process them. Remember, .tsv files are tab separated values, meaning that the entries are separated by tabs rather than commas see here for more information.
Read in the file and store each record as an element within a list.
In:
Task 2
If you look at the records, you find that the latitudes and longitudes of cases are sometimes formatted strangelyapparently the automatic text recognitition software used by the company has a few bugs in it! Go through the records and prompt the user to input the corrected values in cases where the elements cannot be processed as numbers.
In:
Task 3
Its time to format the data so that you can transfer it to the JavaScript portion of your work. Please write the code out to another file called sampleoutput.txt using the tab separator t, and put the file in the same directory as this Jupyter notebook.
In:
Task 4
The company wants you to create a kind of object called a CaseStudy to help them deal with all of the records associated with this file. The CaseStudy object will allow them to associate each latlon pair with the count of disease instances in that location; it will also allow the object to calculate higherlevel properties of that set of locations.
The CaseStudy object should have attributes as follows:
an attribute called name: the name of the case study a string.
an attribute called lat: all of the latitudes from the file an array.
an attribute called lon: all of the longitudes from the file an array.
an attribute called count: all of the cases of the disease from the file an array.
The CaseStudy object should be able to:
return the geographic extent of the area the minimum and maximum of both latitude and longitude as a list e.g. minlat, maxlat, minlon, maxlon. Please call this method getExtent.
return the centroid of the points as a list e.g. centlat, centlon. Please call this method getCentroid.
Please make sure that a CaseStudy object can be created by calling the following:var csnew CaseStudyname, lats, lons, cases
In:
javascript
Task 5
As a final step, youre going to copy over the JavaScript object you created in Task 4 and use it to calculate the geographic extent and centroid of the data you wrote out to a file in Task 3. Please take the JavaScript code you wrote in Task 4 and add it to the section where the code saysADD JS HERE .
In:
html
head
style
.mybar height: 30px; margin: 2px; padding: 3px; backgroundcolor: 0000FF; color: FFFFFF; fontsize: 8pt;
whitespace: nowrap;
style
script srcfinalAssessmentCASA0O13.jsscript
script
ADD JS HERE
script
head
body
h3Barchart of Resultsh3pdiv idbarchartdiv
h3Summary Statisticsh3pdiv idsummaryStatsdiv
script
var myBarfunctionx, title
var elementdocument.getElementByIdbarchart;
var divdocument.createElementDIV;
div.setAttributeclass, mybar;
div.style.widthx10px;
div.innerHTMLtitle;
element.appenddiv;
;
var myStatsfunctioncs
var elementdocument.getElementByIdsummaryStats;
element.innerHTMLThe summary statistics for Case Study bcs.nameb are:br;
element.innerHTMLbrbGEOGRAPHIC EXTENT:b cs.getExtent;
element.innerHTMLpbCENTROID:b cs.getCentroid;
;
var summariseCaseStudiesfunctiondata, filename
var csnew CaseStudyfilename, , , ;
var i;
var rawDatadata.splitn;
fori0; irawData.length; i
var linerawDatai.splitt;
ifline.length1 continue;
cs.lat.pushNumberline0;
cs.lon.pushNumberline1;
cs.count.pushNumberline2;
myBarline2, line0, line1;
myStatscs;
;
var filenamesampleoutput.txt;
readInFilefilename.thenresponsesummariseCaseStudiesresponse, filename;
script
body
Reviews
There are no reviews yet.