Clear Skies

I have worked over the past year or so to speed up routine reporting tasks with rudimentary code. Python gave me the most success, and I still rely heavily on Excel formulas. Argus prefers the statistics language R.

R easily chews through the massive sheets of data I review as an energy reporter. But coaxing conclusions back out of that maw has proven a much more finicky conversation than Python and certainly harder than the formulas I cobbled together over a decade in Excel. Still, I try to figure out new problems using R first as often as possible when coding for work.

The collapse of the air transportation industry offers one of the clearest illustrations of economic devastation wrought by global efforts to mitigate COVID-19. Major US air carriers slashed their capacity in March and April with dizzying speed. But without access to data about scheduled flights, it was tough to get a sense of the drop.

The US Transportation Safety Administration began posting data about daily passenger screenings beginning in March. These popped up in a simple HTML table updated every morning with the previous day’s total. Nice! This simple year-over-year comparison is very helpful for several reasons.

Screen capture of https://www.tsa.gov/coronavirus/passenger-throughput on 12 April, 2020.

First, it’s much more timely information than government agencies usually make available. You can usually wait weeks, if not months, for this kind of data to go public. Second, it’s published with context that illustrates how the current data is changing. Sure, it’d be great to see a few years of the same data, instead of just one year. But giving year-over-year data still means we can draw some very apples-to-apples comparisons about the current year by comparing it to the same travel season last year. One additional helpful bit is that TSA is giving the information compared to the same day of the week as 2019, not simply the exact same date. This is helpful because in normal circumstances travelers favor specific days of the week. Simply comparing 12 April, 2020, to the same day of 2019, would fuzzy up the comparison by using different days of the week.

This is useful data. And because it’s in a simple table, it is very easy to grab with a script, a task called scraping.

R has a package called rvest that will help make this easy. I’m going to also call in some tools from a huge and useful library called tidyverse. Tidyverse also has tools to help the computer understand dates in the first column, but at the time I wrote this I was using a package called anytime to process those. Finally, I’ll use ggplot2 to show me what’s happening over time.

library(rvest)
library(anytime)
library(tidyverse)
library(ggplot2)

First, I need to tell my script what to grab. Obviously, it’s going to need the website’s URL. I also need to tell it where on the webpage it should look.

I’m going to do this with the website’s xpath, which tells my script how to navigate the website. It’s the computer equivalent of telling it to look at the table below the masthead. xpath is simple to find. Modern browsers make this really easy when inspecting a page’s source.

OK, so I can now describe through R how to find the table we want. I’m still learning rvest at this point, so for now I’m going to use tools called xml2 and html_table() in the package to read the table. Why? Because I’m learning R pretty much the same way I learned higher-level Excel: Google the question and try the most recent answers. This is not a great way to go about it! R has changed a lot over the years. But it does let you eavesdrop on lots of conversations of people who struggled with solving these questions before you.

# fetch the latest screening numbers
url <- "https://www.tsa.gov/coronavirus/passenger-throughput"
TSA <- url %>%
  xml2::read_html() %>%
  html_nodes(xpath='//*[@id="node-page-25164"]/div[1]/div/div/div/table') %>%
  html_table()

Alright! I parked the url in a variable called “url”. Then I told rvest to look at the code that makes up the TSA website, find the table, and scrape the table into a variable called “TSA”. This comes out of rvest in a list format, and I want it in a dataframe, so I’ll need to deal with that next.

I’m going to create a dataframe called “passengers.” I’m going to label my columns of data and trim the old headings. I’m going to tell R to treat the text that writes out dates as dates that a computer understands. I’m going to make sure R knows that the rest of the numbers are, actually, numbers. Finally, I’m going to go ahead and create a column that tells me what the 2020 traffic represents as a percentage of last year’s traffic.

I’d use iterative processes called loops to do this in Python. You can do this in R, too — but I can’t, consistently. So this code does it the longer but clearer way.

# process the HTML table into a data table with numbers and a percentage calculation
passengers <- TSA[[1]]
colnames(passengers) <- c("Date", "Current", "Year-ago")
passengers <- passengers[-1,]
passengers$Date <- anydate(passengers$Date)
passengers$Current <- as.numeric(gsub(",", "", passengers$Current))
passengers$`Year-ago` <- as.numeric(gsub(",","", passengers$`Year-ago`))
passengers  <-  mutate(passengers, 
  pc = round((passengers$Current / passengers$'Year-ago' * 100), 1)
)

There’s one more thing I want to do, right off the bat. This TSA data kind of appeared from nowhere. It showed up in March, back dated to the first of the month. That tells me it could disappear at any time, too. So I’m going to write a copy of that data onto my computer for later, just in case.

write.csv(passengers,"<not a real path posted to the internet>tsa_screen.csv", row.names = FALSE)

Now for where R shines: instant graphs! let’s take a look at what the data looks like over time. I’m going to tell R to gather up my dataframe into a tall set so I can plot the two years against each other. I’m going to tell it not to get confused about my percentage column or the dates. Then I’m going to do some quality of life bits, like telling the scale to include commas, giving it a title, and making sure I cite my source.

# plot the current and year-ago screenings
passengers %>%
  gather(key = "When", value = "passengers", -Date, -pc) %>%
  ggplot(., aes(x=Date, y=passengers, col=When)) +
  geom_line(size=1.2) +
  scale_y_continuous(labels = scales::comma) +
  labs(title = "TSA Passengers Screened",
       caption = "Source: Transportation Security Administration",
       x = element_blank(),
       y = element_blank()) +
  theme(plot.title = element_text(hjust = 0.5))
Quick plot of the plummeting US passenger screening data.

Ouch.

I need one last thing, and it’s the bit that I struggle with in R the most. The plot is great for showing the story at a glance. But I’m a writer. I need the numbers R found. So for want of a pretty way to do this, I’m just going to tell it to show me the latest day of data.

# What is the latest number of passengers screened?
passengers[1,]

        Date Current Year-ago  pc
1 2020-04-11   93645  2059142 4.5

Just 4.5 percent of air travelers screened last year on the Saturday of Easter weekend checked in yesterday. An incredible collapse.

And now that I’ve written the script, my computer will check and record this information in the background while showing me the latest update on screenings. No more visiting the website, no risk of errors of transcription or new math problems.

US gasoline cracks fall to negative territory

Read this at ArgusMedia.com: Published date: 17 March 2020

Benchmark gasoline prices fell below regional crude settlements yesterday in major US fuel markets, a rare spring inversion responding to the demand destruction of a global effort to contain the spread of the new coronavirus.

Regional sweet benchmark crudes settled higher than corresponding gasoline benchmarks in the US Atlantic, Gulf and west coasts and the midcontinent, based on Argus assessments. Gasoline in each case was worth less than a barrel of certain sweet crudes purchased to produce it. The fuel retained a premium to sour crude benchmarks in the US Gulf coast, midcontinent and in the Los Angeles, California, market. Overall refining crack spreads — a measure of refinery profitability — were sharply lower but kept positive on the strength of diesel margins.

Cities have ordered residents to shelter in place, states have closed restaurants and bars, and the federal government yesterday urged anyone able to work from home for the next two weeks to do so to limit the spread of the coronavirus. Deep cuts to gasoline consumption were inevitable, though not yet quantified by the Energy Information Administration.

The gasoline discounts to crude happen occasionally, including last February in the New York Harbor, US Gulf coast and midcontinent markets. The reversal more often occurs in January or February, when US gasoline demand shrinks. But they last happened at the same time across these four regions in December 2014.

A barrel of Buckeye RBOB in the New York Harbor fell to a $3.23/bl discount to Brent. Colonial M grade conventional gasoline fell to a 56¢/bl discount to WTI Houston and a 36¢/bl discount to Light Louisiana Sweet (LLS). San Francisco CARBOB dropped to a 18¢/bl discount to Alaskan North Slope (ANS). No market began March below a $5/bl premium to their respective regional crude.

Diesel premiums to crude settled yesterday above the five-year weekly average in the Atlantic and west coasts. But refinery margins yesterday settled at least 50pc lower than that same five year average period in every region.

The Nymex April RBOB contract settled today at 71.14¢/USG, higher by 2.15¢/USG than the previous settle. Regional differentials to that benchmark were falling in the US Gulf coast, Chicago and San Francisco markets. New York Harbor Buckeye RBOB was slightly higher from yesterday’s midpoint in afternoon trade.

By Elliott Blackburn

Renewable diesel makes inroads in California

Production of California’s boutique diesel fell last year to the lowest levels in decades as renewable alternatives gained market share in the state.

In-state output of diesel approved for California roads plunged to the lowest fourth quarter volume on record last year, according to the California Energy Commission (CEC), despite available tax data suggesting higher overall diesel consumption. Refiners meanwhile boosted production of non-California diesel to the highest levels in at least two decades and ramped up exports of fuel oil.

Renewable diesel, an alternative diesel that blends seamlessly with its petroleum-based cousin, rapidly grew its market share in the state transportation pool as the mix of diesel supply flipped, according to the California Air Resources Board (CARB). The shift illustrates how US refiners have adapted asa major market seeks to slash their traditional products.

“When we look at opportunities to produce products where there is going to be growth in the market and they are going to have sustainably high margins, we look to renewable diesel,” Valero chief executive Joe Gorder said in October.

CARB crash

California refiners had not since 2003 produced less than an annual average 200,000 b/d of diesel approved for the state’s roads, called CARB diesel. The stretch dated back to before California’s modern fuel requirements took effect. Average production in 2019 fell by a third from 2018, the largest year-to-year decline on record and more than double a 2009 drop as the state navigated a recession.

But California diesel demand was steady for much of 2019, according to a combination of state and federal data. Taxable gallons recorded by the most recent California Department and Tax and Fee Administration data show a 1.3pc increase, to 204,000 b/d, through the first nine months of the year. While short of the more than 2pc increases in implied demand seen for three consecutive years for the same periods in 2015, 2016 and 2017, the modest increase reversed a decline in 2018.

Fuel prices over the course of the year also cannot fully explain the shift, based on Argus assessments. San Francisco CARB and non-CARB diesel were at parity for almost all of 2019, while the Los Angeles market offered a steady premium for CARB fuel. That premium narrowed over the course of the year to within a 7¢/USG range from the previous year’s 9.5¢/USG premium.

Renewable diesel surge

Credit prices to comply with the state’s green fuel standard moved more dramatically. Renewable diesel supported by the state’s Low Carbon Fuel Standard took steadily larger bites of state fuel demand. The fuel, which blends seamlessly with petroleum diesel and can use existing pipelines and other infrastructure, accounted for 10.2pc of the California diesel pool in 2018. Renewable diesel increased that share by more than 60pc to 17.2pc in the first half of 2019, racing past biodiesel as the lead diesel alternative.

Credit prices over the same period increased the spread between average California renewable diesel credits and conventional diesel penalties by almost a third. That gap has doubled since 2017.

US independent refiners Marathon Petroleum, Phillips 66 and Valero and majors Shell and BP have all planned renewable diesel projects. Oil majors Shell and BP have also planned west coast renewable diesel plants. Independent refiner PBF Energy plans to join a proposed Shell plant at the 155,000 b/d Martinez refinery that PBF plans to buy from the major during the first quarter.

Valero already operates an 18,000 b/d renewable diesel plant in Louisiana that it plans to expand to 44,000 b/d in 2021. California’s commitment to the program, along with rising interest in the fuel in Canada, Europe and New York, supported investments in the fuel, Valero senior vice president of alternative fuels Martin Parrish said during a third quarter conference call.

“We think the future demand for renewable diesel just looks very strong,” Parrish said.

New focus

But California refiners did not ramp down overall diesel production, according to the CEC. Non-California diesel production climbed above 200,000 b/d for the first time in CEC records, and stayed there through the last three quarters of 2019. Output of non-California diesel consistently surpassed CARB diesel production for the first time since CEC records began in 1999.

Refiners and traders have not discussed where that production flowed, and federal and state data does not give a complete picture of consumption in neighboring states.

State tax records show that Nevada diesel and biodiesel consumption increased by almost 5pc in the first 10 months of 2019 compared to 2018. Both Los Angeles and Utah supply that state. Arizona state fuels information was not available, and federal data offers only an incomplete estimate of higher consumption for 2019.

Federal export data and vessel tracking by analytics firm Vortexa show fairly typical diesel exports from California over 2019. But fuel oil exports loading from California began ramping up beyond year-ago levels in August as diesel exports shrank, according to Vortexa.

EPA grants 31 Renewable Fuel Standard waivers

Prices for US renewable fuel blending credits plunged today ahead of the Environmental Protection Agency’s (EPA) approval of 31 exemptions for small refineries of their federal biofuel obligations for 2018.

The agency rejected six of the 2018 applications and the single remaining applications for the 2016 and 2017 compliance years. The decisions marked the first rejected requests to waive Renewable Fuel Standard (RFS) requirements under President Donald Trump’s administration and since 2016.

A final 2018 application was withdrawn.

The decisions effectively waived 7.4pc of the requirements for the 2018 compliance year, freeing up credits needed to comply for future years of the program. Farm and biofuels groups immediately condemned the announcement, which arrived three weeks late and followed a heated summer of debate over EPA’s administration of the mandates.

Prices for ethanol-associated renewable identification numbers (RINs) traded as low as 11¢/RIN this afternoon ahead of the statement, down from a 20¢/RIN settle yesterday, based on Argus assessments.

“The EPA has proven beyond any doubt that it does not care about following the law, American jobs, or even the president’s promises,” ethanol trade group Growth Energy chief executive Emily Skor said. “Now farmers and biofuel producers are paying the price.”

RFS requires that refiners, importers and certain other companies each year ensure minimum volumes of renewables enter the gasoline and diesel they add to the US transportation fuel supply. Refiners prove annual compliance with renewable identification numbers (RINs) representing each ethanol-equivalent gallon of blended fuel acquired through their blending businesses or by purchasing the credits from others.

Congress included an exemption for refineries processing less than 75,000 b/d of crude a year that could demonstrate a hardship under the program to the Energy department and EPA. EPA issued relatively few such waivers under former president Barack Obama’s administration, but their use surged under Trump’s first EPA administrator, Scott Pruitt, and following a series of judicial rebukes of the difficult Obama administration criteria.

These waivers effectively reduce total annual mandates because the EPA does not shift the waived requirements to other, larger obligated parties. A record 35 waivers issued as of March this year for 2017 reduced obligations for that compliance year by 9.4pc.

Exemptions for the 2018 compliance year waived 1.43bn RINs.

Ethanol advocates have especially railed against the waivers, insisting the exemptions slashed demand for their fuel and associated corn feedstock as Trump’s trade wars and widespread flooding crush farm incomes this year. The waivers have more directly affected biodiesel blending refiners historically used to make up the difference between the total volume of annual ethanol demand and mandated renewable blending volumes.

Refiners have argued that the courts determined EPA was only now properly issuing waivers.

“Capital planning is difficult without knowing whether your refinery needs to set aside millions of dollars for RIN purchases,” the Small Refiners Coalition said. “The decision to grant small refinery hardship is a legal decision, not a political one, and we are pleased that [the department of Agriculture’s] influence did not cause EPA to depart from the rule of law.”

EPA pledged to “remove regulatory burdens” for new pathways of renewable fuels to use to comply with the program, and touted work with the National Corn Growers Association to expedite approval for the herbicide atrazine.

“EPA is committed to an expeditious and transparent process to ensure that America’s corn growers have the tools they need to grow safe, healthy and abundant food for all Americans and a growing population,” the agency said.

Litigation continues against EPA’s handling of the program. The US Court of Appeals has scheduled a late October hearing on an Advanced Biofuels Association challenge to the agency’s use of the program.

Ruling affirms Citgo risk to Venezuelan debts

Appellate judges today affirmed that companies may seek shares of entities controlling US independent refiner Citgo to satisfy billions of dollars in Venezuelan debts.

The decision could upend control of Venezuela’s most valuable overseas asset and a key anchor to the impoverished country’s loans, opening a path to compensation for more than a dozen entities with assets expropriated by Venezuelan governments. An auction of Citgo shares could move forward as early as September unless the US Treasury’s Office of Foreign Assets Control (Ofac) declares such transactions blocked by US sanctions, a senior financial sector executive close to Venezuela’s creditors told Argus.

The unanimous three-judge panel also rejected arguments that third-party bondholders must be considered in reaching that decision, finding that any lenders to national oil company PdV had ample notice of the government’s involvement in the company.

Venezuelan attorneys argued that the country’s interests in Citgo were immune from such attachments. But the US Third Circuit Court of Appeals panel found that Venezuela’s involvement in PdV easily cleared a legal determination that the company effectively served as alter-ego of the Venezuelan government, and that entities seeking assets to satisfy numerous arbitration awards could attach its US companies controlling Citgo.

“Indeed, if the relationship between Venezuela and PdV cannot satisfy the Supreme Court’s extensive-control requirement, we know nothing that can,” the opinion said.

Judges affirmed a district court finding last fall that Citgo assets were directly held by Venezuela despite the use of US subsidiaries. That finding allowed the defunct mining firm Crystallex, now controlled by New York-based investment firm Tenor, to seek payment of a $1.2bn arbitration award for Venezuela’s expropriation of the company’s Las Cristinas gold mining assets almost a decade ago.

“The Third Circuit’s decision is a crucial step in getting Venezuela finally to honor its legal obligations,” Crystallex chief executive Bob Fung said. “We look forward to proceeding with our lien to recover at least part of our expropriated investment in Venezuela.”

PdV did not comment, and Citgo and Treasury did not respond to requests for comment.

Appellate court judges in Philadelphia questioned in an April hearing why Citgo should be immune from the billions of dollars of debts accrued by the Venezuelan government. The panel said today that Venezuelan national oil company and Citgo owner PdV failed to show significant separation between the government and the national oil firm.

Citgo’s 750,000 b/d of complex refining capacity and fuel network west of the Rocky Mountains make a lucrative target for the country’s creditors, who seek more than $150bn. These most valuable overseas assets fall subject to the US court system and an executive branch that does not recognize President Nicolas Maduro’s government.

That change in White House recognition has rippled through more than a dozen separate petitions in US courts for recognition of arbitration awards for expropriated assets over the past decade. The US-recognized opposition headed by National Assembly leader Juan Guaido repeatedly requested judges overseeing petitions from oil services companies, defense contractors, plastics manufacturers and ranchers to delay proceedings so the new leadership could review the cases — and judges almost always said yes. The Third Circuit recognized Guaido’s representatives as speaking for Venezuela, though noted “there is reason to believe that Guaido’s regime does not have meaningful control over Venezuela or its principal instrumentalities such as PdV.” The government dropped requests for a stay in this case as oral arguments began.

The appellate opinion dealt another setback to the Venezuelan opposition. Guaido declared himself interim president on 23 January, a move recognized by the US and more than 50 western governments that led directly to US sanctions on PdV. Guaido-appointed directors have controlled Citgo since February. But both the Maduro and Guaido governments now face a potential loss of control over its profitable US refining system and the exit of US oil major Chevron as a key bond payment comes due in October.

Crystallex “repeatedly reached out to Venezuela’s interim government to seek a fair settlement that would compensate Crystallex for its property and preserve the value of Citgo for the Venezuelan people,” the company said today.

The company was asked if that offer was extended.

“We look forward to proceeding with the legal process to recover the value of our expropriated investment in Venezuela,” the company said.

turnaround

Heavy supplies shrink for US refiners

Tariff threat narrows US heavy crude options

originally published 31 May, 2019.

President Donald Trump’s threats to impose tariffs on imports from Mexico dealt the latest blow to US heavy crude supply options already narrowing under his administration this year.

Actions against Mexico would join sanctions against Venezuela and Iran and infrastructure constraints from Canada in trimming a key competitive advantage for the most complex US refiners. Trade groups warned the measure could increase US retail fuel prices.

“We thus urge the president not to pursue energy tariffs against one of our most important trading partners,” American Fuel and Petrochemical Manufacturers chief executive Chet Thompson said.

Trump late yesterday said he would impose escalating tariffs beginning at 5pc on “all goods” from Mexico starting 10 June unless the country did more to halt illegal crossings of the US-Mexico border. Tariffs would increase by 5pc each month until a final 25pc in October.

Imports of Mexican heavy crude surged in March, according to the latest Energy Information Administration data. US buyers scrambled to replace heavy, sour supplies from Venezuela, which had been blocked by US sanctions imposed on 28 January on national oil firm PdV. Mexico was the second highest source of 20°API or lower crude after Canada, a role the country’s heavy production has not played for US refiners since 2011. Venezuelan production, the single largest US source of heavy crude from 2003 to 2017, shrank to fifth in March out of seven suppliers.

Mexican heavy was 27pc of all heavy crude imported for the month. Colombian and Brazilian heavy production also showed marked increases in March compared to the same month of 2018.

Refiners privately said 5pc would not be an immediate, severe impediment. But the potential escalation was a concern. Shell, the largest regular US importer of Mexican heavy crude and operator of a 340,000 b/d refinery in Deer Park, Texas, in a joint venture with Mexico’s national oil company, Pemex, could not be immediately reached for comment. Chevron, the second-largest routine importer of Mexican heavy crude, cautioned against US trade measures that could invite a response.

“Chevron supports free and fair trade, and believes the imposition of new tariffs should be balanced against the potential for retaliatory actions that impair the development of new markets,” the oil major said.

Mexico’s slow liberalization of its oil market has made it an attractive investment for oil majors and US independent refiners. Marathon Petroleum has expanded its Arco brand across western Mexico, integrating a wholesale business there with its western US refineries. Valero invested in port and inland infrastructure in central and eastern Mexico, while BP, Chevron, Shell and Total have all expanded retail businesses over the same area.

But it would be difficult for Mexico to spurn such businesses in retaliation. Mexico imported 71pc of its gasoline demand for the first two weeks of May from the US. US diesel satisfied 77pc of demand over the same period.

Mexico has worked to increase its destinations for crude. US was still the main destination of Mexico’s crude exports in April, taking 58pc, or 594,000 b/d. Asia received another 296,000 b/d, or 29pc, and Europe 133,000 b/d, or 13pc.

“Pemex has been sending now an increasing percentage of its production to the Netherlands and some part of Asia,” Mercury Energy Consultants analyst Arturo Carranza said. “This has been part of a long-term strategy to depend less on US purchases.”

US refiners, meanwhile, must continue to hunt for heavy feedstocks as the industry exits an intense maintenance period in the first half of this year. July prices for Western Canadian Select (WCS) — the new king of US coking units — have crept toward discounts supporting costlier railed shipments of the crude.