The Texas oil and gas sector has turned the corner after a two-year "blood bath" that humbled the nation's top producer, a state economist said.

Texas is the top oil producer in the country and most of the oil and gas drilling and exploration activity occurs there because of its rich shale resources. Karr Ingham, an economist at the independent Texas Alliance of Energy Producers, said data he watches show clear signs of recovery for the first time since late 2014.

"It's been a bloodbath, frankly, but better days are ahead in 2017 after two years of sharp contraction, job losses, and downward pressure on the statewide and regional economies of Texas," he said in a statement.

A so-called Beige Book produced by the Federal Reserve Bank of Dallas in 2015 found most companies working in the exploration and production side of the energy sector expected their capital expenditures to fall by up to 40 percent. Crude oil prices by then had lost about 50 percent of their value from the peak of the shale era in 2014 and dropped to historic lows by the start of 2016.

Improved efficiencies in shale drilling operations and a spending response to the higher crude oil prices that greeted a late 2016 decision by the Organization of Petroleum Exporting Countries meant recovery for the Texas energy sector.

The Texas Railroad Commission reported an average preliminary crude oil production for November of 2.4 million barrels per day, an increase of about 2 percent year-on-year. Energy executives responding to a survey from the Dallas Fed said the outlook for 2017 had improved over last year. During the fourth quarter, state oil and gas production held relatively stable and measured indices showed gains in oil in particular.

"This is the moment we've been waiting for," Ingham said. "It is good news for the industry, for the Texas economy, and for many communities around the state that are strongly connected to the oil and gas exploration and production industry."